This post deals with passing of an integer value from one
UIViewController class to another UIViewController class…
Suppose there are two UIViewController classes
FirstViewController
SecondViewController
Now we have to pass an integer value from FirstViewController to SecondViewController
We can use @property to pass values from one class to another but the problem is that the property can be a object only
So we will have to use NSNumber object to store int value as an object and later use it as a property
In the SecondViewController.h file
write
NSNumber *value;
@property(nonatomic,retain) NSNumber *value;
In the SecondViewController.m file
@synthesize value; after @implementation
In the FirstViewController.m file
SecondViewController *second=[[SecondViewController alloc] initWithNibName:@”SecondViewController” bundle:nil];
testing.value=[NSNumber numberWithInt:9];
Don’t forget to include SecondViewController.h file in the FirstViewController.h file.
Now in SecondViewController.h file access the value of property by
[self.value intValue]