Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three20 : how to pass a class of objects between 2 views

I have a TTableView. The items in this table a mapped to an url, so that when I click on an item, another view appear with informations about this item. All these informations are attributes of a class. So, how can I build my TTableTextItem URL in order to transmit the class containing informations to the view responsible for the display of these informations ?

Thanks in advance.

like image 335
Harkonnen Avatar asked Oct 16 '10 14:10

Harkonnen


1 Answers

One way of doing it is to use a TTURLAction. When the user selects a row in your table, which will call your didSelectObject (of TTTableViewController) method, extract the object or set of objects you want to pass and build a TTURLAction like this:

TTURLAction *action =  [[[TTURLAction actionWithURLPath:@"tt://showUser"] 
    applyQuery:[NSDictionary dictionaryWithObject:user forKey:@"kParameterUser"]]
            applyAnimated:YES];

Then open the action:

[[TTNavigator navigator] openURLAction:action];

The controller you want to open as a result of this action should be registered in your TTURLMap and should have a constructor thus:

- (id) initWithNavigatorURL:(NSURL*)URL query:(NSDictionary*)query {
    self = [super init];
    if (self != nil) {
        self.user = [query objectForKey:kParameterUser];
    }
    return self;
}

I tend to create categories on classes for objects I want to be able to open another controller and display themselves.

like image 87
lyonanderson Avatar answered Jan 21 '23 04:01

lyonanderson