开发者

How to transmit data from file to file in xcode 4?

I'm an absolute beginner in iphone development (actually i've been studying it just for three days ) and one thing which i have to implement is not understandable to me. I need to create multiview application which comprises three views. The text entered at the first screen via text fields and the image chosen at second one should be displayed at the third screen. But each view is a separate set of files. What should i do to make my variables which hold values of text and image visible in the third set of files? In C++ there is EXTERN key word for such things if i'm not mistaken. But may be i should organiz开发者_如何学编程e my project in some different way? Should i use view controller? And what type of project it is better to choose? View based? Window based? Navigation based? Would you please explain me what to do?


Yes, you should use view controllers. One for each view. Define all the data you want to have sent around as a property, so it's easy to deal with. In your first viewController, read in the text. Then create the second view controller and copy the text into the second view controller. From the second view controller, create the third view controller and copy the text and the image down to the third, which is where you need it. You have to be mindful of retaining all these so either the original definition of the data needs to be retained, or retain and release it through all the stages.

SecondViewController * svc = [[SecondViewController alloc] initWithNibName...
svc.theText = self.myText;

Repeat for the image in the third viewController.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜