Search Results

Search found 1 results on 1 pages for 'user544359'.

Page 1/1 | 1 

  • Obj-C Sending Messages Between Classes

    - by user544359
    I'm a newbie in iPhone Programming. I'm trying to send a message from one view controller to another. The idea is that viewControllerA takes information from the user and sends it to viewControllerB. viewControllerB is then supposed to display the information in a label. viewControllerA.h #import <UIKit/UIKit.h> @interface viewControllerA : UIViewController { int num; } -(IBAction)do; @end viewControllerA.m #import "viewControllerA.h" #import "viewControllerB.h" @implementation viewControllerA - (IBAction)do { //initializing int for example num = 2; viewControllerB *viewB = [[viewControllerB alloc] init]; [viewB display:num]; [viewB release]; //viewA is presented as a ModalViewController, so it dismisses itself to return to the //original view, i know it is not efficient [self dismissModalViewControllerAnimated:YES]; } - (void)dealloc { [super dealloc]; } @end viewControllerB.h #import <UIKit/UIKit.h> @interface viewControllerB : UIViewController { IBOutlet UILabel *label; } - (IBAction)openA; - (void)display:(NSInteger)myNum; @end viewControllerB.m #import "viewControllerB.h" #import "viewControllerA.h" @implementation viewControllerB - (IBAction)openA { //presents viewControllerA when a button is pressed viewControllerA *viewA = [[viewControllerA alloc] init]; [self presentModalViewController:viewA animated:YES]; } - (void)display:(NSInteger)myNum { NSLog(@"YES"); [label setText:[NSString stringWithFormat:@"%d", myNum]]; } @end YES is logged successfully, but the label's text does not change. I have made sure that all of my connections in Interface Builder are correct, in fact there are other (IBAction) methods in my program that change the text of this very label, and all of those other methods work perfectly... Any ideas, guys? You don't need to give me a full solution, any bits of information will help. Thanks.

    Read the article

1