Hy I am a beginner at Objective-C Programming. I declare a NSString @interface.
This member I would like to write by a method and read by a other method. But this won't work. The program kills.
This is a part of my code. I hope any one can help me.
This member I would like to write by a method and read by a other method. But this won't work. The program kills.
This is a part of my code. I hope any one can help me.
Code:
@interface MainViewController : UIViewController <FlipsideViewControllerDelegate> {
IBOutlet UITextField * _username;
IBOutlet UITextField * _password;
IBOutlet UIButton * _loginout;
IBOutlet UIActivityIndicatorView * _activity;
NSString * _token;
}
- (IBAction)showInfo:(id)sender;
- (IBAction)logInOut:(id)sender;
@end
@ implementation
.....
- (void)viewDidLoad {
_token = [[NSString new] retain];
_token = [_token stringByAppendingString: (NSString * )[json_header objectForKey: @"token"]];
NSLog(@"%@", _token]; // Here all right!!
}
//! Build the data string for the login.
/*!
*/
- (NSString *) buildLoginFormData
{
assert (_token != nil);
NSString * str = @"username=user1&password=1234&";
// At this point the program kills
//NSLog(@"Token: %@", _token);
str = [str stringByAppendingString: _token];
return str;
}
- (IBAction)logInOut:(id)sender
{
NSString * data = [self buildLoginFormData];
}
.....
@end