简体   繁体   English

在视图控制器之间传递对象的three20方法是什么?

[英]What is the three20 method of passing objects between view controllers?

I have a basic RSS Reader I made from three20 tutorials using TTLauncherView as a menu to different feeds and TTTableViewController to show the feed list.我有一个基本的 RSS 阅读器,我使用 TTLauncherView 作为不同提要的菜单和 TTTableViewController 来显示提要列表,它是根据三个 20 个教程制作的。

However, I am stuck at the point where from the feed list I click to view the feed item details.但是,我停留在从提要列表中单击以查看提要项目详细信息的位置。 I use TTTableImageItem to display my feed items and I'm clueless as to how I am to use the URL variable in said TTTableImageItem to pass objects to the view controller showing the feed item.我使用 TTTableImageItem 来显示我的提要项目,但我不知道如何使用所述 TTTableImageItem 中的 URL 变量将对象传递给显示提要项目的视图 controller。

I did some searching and I am lead to think that this cannot be done except via TTURLRequest, which leaves me even more confused.我做了一些搜索,我认为除了通过 TTURLRequest 之外无法做到这一点,这让我更加困惑。

Most of my code is adapted from IOSGuys tutorial, which uses a custom data source, data model and parser.我的大部分代码改编自IOSGuys教程,它使用自定义数据源、数据 model 和解析器。 I have tried making the data source and data model a singleton but to no avail and I'm unsure if that's even the best way to proceed for something as (presumably) simple as this.我尝试将数据源和数据 model 设为 singleton 但无济于事,我不确定这是否是处理(大概)这样简单的事情的最佳方法。

Ideally I intend to pass the entire array of feed items with another argument for the index so that I can make use of UIPageControl to swipe between feeds when I'm at a more in-depth view.理想情况下,我打算将整个提要项数组与索引的另一个参数一起传递,这样当我处于更深入的视图时,我就可以使用 UIPageControl 在提要之间滑动。

Much help is appreciated!非常感谢您的帮助! I have been spending too long looming around already!我已经花了太长时间隐约可见了!

The usual way of doing this is to have some sort of global singleton Data Manager class that manages the data models through Core Data, In-Memory Stores or other ways.这样做的通常方法是使用某种全局 singleton Data Manager class 通过核心数据、内存中存储或其他方式管理数据模型。 Each model would have some sort of unique identifier.每个 model 都会有某种唯一标识符。 Doing it this way lends itself to a URL only stack needed to recover your navigation history without having to write state out to file in order to restore.这样做可以让 URL 仅用于恢复导航历史记录所需的堆栈,而无需将 state 写入文件以进行恢复。 You also can bring up any page in the app at any place with only a single URL.您还可以在任何地方打开应用程序中的任何页面,只需一个 URL。 Using a URL scheme only then becomes trivial as you can do something like:使用 URL 方案才变得微不足道,因为您可以执行以下操作:

yourapp://blogs/jd82kd9

and have the blog view controller's init method contact the Data Manager for the blog with the unique identifier of jd82kd9并让博客视图控制器的init方法与唯一标识符为jd82kd9的博客联系Data Manager

In your navigator's mappings, you would have something like this:在你的导航器的映射中,你会有这样的东西:

[map from:@"yourapp://blogs/(initWithBlogID:)") toViewController:[MyBlogViewController class]];

and then the initWithBlogID method would have the signature:然后initWithBlogID方法将具有签名:

- (id)initWithBlogID:(NSString *)blogID;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM