Supertecnoboff
Supertecnoboff

Reputation: 6606

Pass Integer to another UIView

I'm trying to pass an Integer variable from one UIView to another. Basically, I have two UIView controllers set up. The first UIViewController has an integer called "page" and the seconds UIViewController has an Integer called "page_num".

What I am trying to do is to pass the variable from the Int "page" to the Int "page_num". But I get the following error:

Property 'page_num' not found on object of type 'ImageViewer *'....

Here is my code (header file):

ImageViewer *seccondata;
@property (nonatomic, retain) ImageViewer *seconddata;

Here is my code (implementation file):

ImageViewer *screen = [[ImageViewer alloc] initWithNibName:nil bundle:nil];
self.seconddata = screen;
seconddata.page_num = page;
screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:screen animated:YES completion:nil];

What am I doing wrong? The code I have shown above worked when I wanted to pass a NSString from one UIViewController to another.

Upvotes: 0

Views: 354

Answers (3)

Jitendra
Jitendra

Reputation: 5081

First you need to create the second class objcet. and acess that varible using that objcet like objcet.property.

Like Below code

ImageViewer *screen = [[ImageViewer alloc] init];
screen.page_num = page;

Try this code..

Upvotes: 0

Nasir
Nasir

Reputation: 431

you should create the the object of the second class and access the variable with the help of that object..

Upvotes: 0

Divyam shukla
Divyam shukla

Reputation: 2048

ImageViewer *screen = [[ImageViewer alloc] initWithNibName:nil bundle:nil];
screen.page_num = page;
[self presentViewController:screen animated:YES completion:nil];

Try this and no need to create any property.

Upvotes: 2

Related Questions