three20 URLMAP 对象传递方法

原文是这样的:http://three20.info/article/2010-10-06-URL-Based-Navigation#nativeparams

 

[map from:@"tt://menu/(initWithMenu:)"  toSharedViewController:[MenuController class]];

[map from:[Contact class] name:@"view" toURL:@"tt://contact/view/(uid)"];

两种方法:

1.

@interface Contact : NSObject {
 
}
 
@property (nonatomic, retain) NSNumber* uid;
@property (nonatomic, retain) NSString* firstName;
@property (nonatomic, retain) NSString* lastName;
 
@end

 

Contact* aContact = [[Contact alloc]
initWithFirstName:@"Johnny" lastName:@"Appleseed" uid:1];
NSString* url = [aContact URLValueWithName:@"view"]

然后通过

TTOpenURL(url);

 

2.

NSArray *arr = [...load up with data...];
[[TTNavigator navigator] openURLAction:[[TTURLAction actionWithURLPath:@"tt://restaurant/Chotchkie's"]
  applyQuery:[NSDictionary dictionaryWithObject:arr forKey:@"arraydata"]]];

然后在tt://restaurant对应的controller 代码中写上

-(id) initWithName: (NSString*)name query:(NSDictionary*)query {
  for (MyObject* item in [query objectForKey:@"arrayData"])
    //... do something with item ...
  }
 
  // ...
}

 

 转载请说明出处:http://www.cnblogs.com/hubj/archive/2012/05/20/2509596.html

posted @ 2012-05-20 11:58  alex hu  阅读(614)  评论(0编辑  收藏  举报