How do I pass an integer value to another class?

<>

This question already has an answer here:

Answers


Try to synthesize your number in secondClass.m

@synthesize number;

and add the init in your secondClass declaration

hope this help.


maybe you just have a typo in your description but try:

secondClass *second = [[secondClass alloc] init];  
second.number = 15;  
NSlog(@"number is:%d",number);  

Find a similar case. The thing is that I'm using segue for transition from one view controller to another. I solved out problem with method prepareForSegue. Here is the code I was searching:

  -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([segue.identifier isEqualToString:@"NextView"]){
    secondClass *second = (secondClass *)segue.destinationViewController;
    second.number = object.center.x;
   }
}

@property (readwrite) int number;

//first class

    second *move = [[second alloc] initWithNibName:@"second" bundle:nil];
    move.number = 15;
    [self.navigationController pushViewController:move animated:YES];
    [move release];

Need Your Help

S#arp ActionLinkForAreas + Parameters + custom routes - UPDATED!

asp.net-mvc-2 s#arp-architecture actionlink

Does the ActionLinkForAreas link extension work with parameters + custom routes?