Making TTTableItem's pass objects to TTViewController's

26 views
Skip to first unread message

Phil Freo

unread,
Nov 18, 2009, 1:00:27 PM11/18/09
to Three20
In my TTListDataSource tableViewDidLoadModel, I'm currently doing, in
a loop:

TTTableSubtitleItem *item = [TTTableSubtitleItem itemWithText:title
subtitle:desc imageURL:imageURL defaultImage:nil URL:url
accessoryURL:nil];
[self.items addObject item];

But I need to pass an object (not just a string) to the
TTViewController when the TTableItem is clicked.

I know that you can pass an object (NSDictionary) to a
TTViewController using:
[[TTNavigator navigator] openURL: query: animated:YES]

However, since I'm trying to open this URL from a TTTableItem, I don't
know how to use openURL with it where I can pass a query NSDictionary
object, since all it takes as an NSString "URL".

I read here ( http://groups.google.com/group/three20/browse_thread/thread/1f70e6b36ce8999b
) however I'd really, really like to avoid having to modify the
original Three20 code. If it can properly be extended, that would be
fine.

What's the simplest way I can make my table item's open up a
TTViewController and pass an object (such as an NSDictionary)?

uprise78

unread,
Nov 18, 2009, 3:34:24 PM11/18/09
to Three20
What have you tried that didn't work? Have you traced through the
code at all to see where the TTTableItem's url is getting used? Have
you looked through the TTTableViewController's public methods to see
what is available? How about TTTableViewDelegate and TTDataSource?

No offense, but you really need to put a little effort into coding.
It not only will build character but it also will make you a better
coder. Each and every time you trace through the code you will learn
more and more about how it works and then you can use the tools you
acquire to write better and better code.

Fred Potter

unread,
Nov 18, 2009, 3:52:19 PM11/18/09
to thr...@googlegroups.com
Hi Phil,

In the UIViewController that you want to receive this object,
implement the following initializer (defined in
UIViewControllerAdditions):
- (id)initWithNavigatorURL:(NSURL*)URL query:(NSDictionary*)query

Nothing weird is required in the mappings. For example, I have...
[map from:@"tt://blah" toViewController:[MyBlahViewControllerClass class]];

Then, when you wish to open this URL and pass along the query
dictionary, do something like:
[[TTNavigator navigator] openURL:@"tt://blah"
query:myDictionaryFullOfObjects animated:YES];

You mention that you're trying to do all of this within a table view.
As you've noticed, the standard plumbing provided by TTTableLinkedItem
isn't going to help you pass along arbitrary query dictionaries.
You'll need to override the following method which comes along with
TTTableViewController:
- (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath

Maybe you're needs aren't that complex, and you just test which
'object' was selected and call openURL. Maybe you build some fancier
TTTableLinkedItem that also holds a query dictionary along with a URL.
That's up to you.

Hope this helps!

Fred
> --
>
> You received this message because you are subscribed to the Google Groups "Three20" group.
> To post to this group, send email to thr...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/three20?hl=.
>
>
>
Reply all
Reply to author
Forward
0 new messages