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

前端 未结 4 1067
长情又很酷
长情又很酷 2021-02-04 17:18

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 a

4条回答
  •  感动是毒
    2021-02-04 18:02

    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.

提交回复
热议问题