开发者

Get~Set value from different ViewControllers XCode

I have a two ViewControllers

In Level4ViewController I have a NSNumber *averagePred; I would like to get and set the value of averagePred from Level5ViewController.

I have already entered the @property (nonatomic, retain) ... for each.

How can I manage this, I've tried just putting the properties in my AppDelegate and using:

appDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])

This didn't seem to work, and I would like to be able to get this sorted.

And a final part, if anyone can help me on:

I have:

NSNumber *averagePred; In my header file

In the methods I have a float average; and using averagePred = [NSNumber numberWithFloat:average]; didn't work. Can anyone help me out here. Thanks


Level5VC needs a reference to Level4VC, so it can do this:

   myLevel4VC.averagePred = 159.3;

You can give level5 the reference by passing it into a custom constructor, or by having a level4VC ivar in level5 that is set by whoever invokes level5.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜