Hello. I am trying to display some text in a UILabel I have created. The situation is as follows: I have a viewController (AccountCreation) which is connected with a xib file and has a bunch of text input boxes and a button to connect to a server and attempt to create an account. What I am trying to do is display the result of the account creation (success or failure) in a label on this view. The way I have this set up is once the "create account" button is pressed my program heads to my appDelegate who launches the URL connection protocols I've established which then returns to my appDelegate (this is where I would like to update the label). Some code that might be relevant:
And in my appDelegate:
I've noticed that my errorLabel is null inside of here. I've tried creating a method in the viewController to update the label.
Thanks for anyone's help.
Code:
@interface AccountCreation : UIViewController {
IBOutlet UITextField *username,*email,*password,*confirmPassword;
IBOutlet UILabel *errorLabel;
BOOL moveViewUp;
CGFloat scrollAmount;
}
-(IBAction)createAccount:(id)sender;
-(void)scrollTheView:(BOOL)movedUp;
-(void)updateError;
@property(nonatomic,retain)UITextField *username;
@property(nonatomic,retain)UITextField *email;
@property(nonatomic,retain)UITextField *password;
@property(nonatomic,retain)UITextField *confirmPassword;
@property(nonatomic,retain)UILabel *errorLabel;
@end
And in my appDelegate:
Code:
-(void)createAccountAttempt:(NSData *)data
{
AccountCreation *accountController = [[AccountCreation alloc] init];
NSString *accountResponse=[[NSString alloc]initWithData:data encoding:NSASCIIStringEncoding];
NSString *errorLog;
NSRange start,end;
NSLog(@"account creation response: %@",accountResponse);
start=[accountResponse rangeOfString:@"<error>"];
//error with account creation
if(start.location>0)
{
start=[accountResponse rangeOfString:@"<error_msg>"];
start.location+=[@"<error_msg>" length];
end=[accountResponse rangeOfString:@"</error_msg>"];
errorLog=[accountResponse substringWithRange:NSMakeRange(start.location, end.location-start.location)];
// NSLog(@"errorLog: %@",errorLog);
accountController.errorLabel.text=errorLog;
}
[accountResponse release];
}
I've noticed that my errorLabel is null inside of here. I've tried creating a method in the viewController to update the label.
Thanks for anyone's help.