I’m kind of a newbie to objective programming, so sorry for the dumb question.
I’m doing some kind of a messenger for some social network, and i’m stuck at the very simple thing – how to send a message from the object of one class to the object of the another class?
I have a class, called SignInViewController, which creates an instance of SignUpViewController after a SignUpButton is pressed and it’s done just like that:
SignUpViewController *signUpViewController = [[SignUpViewController alloc]init];
signUpViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:signUpViewController animated:YES];
Then, after some management done with the AFNetwork (i use a specific class for this, called ServerManager), i want to send the message to draw a new textfield in my SignUpViewController instance, and i think it could be done like that:
in the SignUpViewController.h:
- (void)showTheCodeTextField;
in the ServerManager.m:
[[SignUpViewController self] showTheCodeTextField];
and then in SignUpViewController.m:
-(void)showTheCodeTextField
{
NSLog(@"Time to draw codeTextField");
}
I am getting a familiar SIGABRT at the latter line of code. I know I am doing something wrong, but I just can’t figure out what exactly.
Could you help me out please?
You can use NSNotificationCenter to make that work.
After presenting your SignUpController you add it as an observer of notifications that ServerManager sends.And when that notification comes, you call your message to draw the view.
So, after
Make an observer
Than, in your Server Manager, you send a notification, containig that textField, and the method in your SignUp gets called.That’s it.You’ve got the textField text in your
notification.userinfoGetting tour Text here in signUpView