So, I have two classes, class A and class B. From class A, when a button is pressed, I have an instance of class B initialize and call its method, testMethod. It sets the text of a a UITextField named text and calls NSLog within this method, but it only calls NSLog when it calls the method! I have no idea what I’m doing wrong, here is my code (Assuming both classes are UIViewController subclasses, and an instance called b was defined in the header file:
ClassA.m
-(IBAction)sendData:(id)sender
{
b = [[ClassB alloc] init];
[b testMethod];
[[self navigationController] pushViewController:b animated:YES];
}
ClassB.m (Yes, the UITextField was propertized and synthesized)
-(void) testMethod
{
[text setText:@"Text"];
NSLog(@"This is the only thing getting called in this method");
}
EDIT: I fixed the problem. What I did was pass a variable to class B from class A and have it set its text field from there.
Based on the information that you provided: You are using IB and you believe hat within Interface Builder everything is hooked up properly.
And assuming that the nib file of your ClassB view controller is “ClassB.xib”.
Instead of
use