开发者

Save value to main controller from pop over controller on the iPhone

I'm new to objective-c and need some help setting this up. Basically, there's开发者_JS百科 the main view and it opens a pop over view. the pop over has a segmented control with 2 buttons. clicking btn1 should save 0 to a variable in the main view, and btn2 should save 1. Closing the reopening the popover should display the previously selected value.

MainViewController.h
NSInteger data;
MainViewController.m

PopOverViewController.h
PopOverViewController.m

Could someone give me some tips on how to do this?


There's no straight forward way to "return" a value from a sub controller, so you can use a simple pointer.

In PopOverViewController, declare an instance variable

NSInteger *data;

...

@property NSInteger * data;

And then set the pointer after you alloc the controller

popOverController.data = &data;

Later btn1 will run

*data = 0;

etc... This sets the value in the original data variable.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜