如何在 xcode 4 中从一个文件传输数据到另一个文件?
我是 iPhone 开发的绝对初学者(实际上我只学习了三天),我必须实现的一件事对我来说是无法理解的。 我需要创建包含三个视图的多视图应用程序。在第一个屏幕上通过文本字段输入的文本和在第二个屏幕上选择的图像应显示在第三个屏幕上。但每个视图都是一组单独的文件。我应该怎么做才能使保存文本和图像值的变量在第三组文件中可见?如果我没记错的话,在 C++ 中有 EXTERN 关键字来表示这些东西。但也许我应该以某种不同的方式组织我的项目?我应该使用视图控制器吗?那么选择什么类型的项目比较好呢?基于视图?基于窗口?基于导航?您能解释一下我该怎么做吗?
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 organize 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您应该使用视图控制器。每个视图一个。将您想要发送的所有数据定义为属性,这样就很容易处理。在您的第一个 viewController 中,读入文本。然后创建第二个视图控制器并将文本复制到第二个视图控制器中。从第二个视图控制器创建第三个视图控制器并将文本和图像复制到第三个视图控制器,这是您需要的地方。您必须注意保留所有这些,因此要么需要保留数据的原始定义,要么在所有阶段保留并释放它。
对第三个 viewController 中的图像重复此操作。
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.
Repeat for the image in the third viewController.