开发者

Multi-parameter mapping with Three20 and TTURLMap

I'm following this tutorial and declare the following mappings in my app delegate:

[map from:@"x://profile/(initWithId:)/(name:)" toViewController:[ProfileViewController class]];
[map from:@"*" toViewController:[TTWebController class]];

In ProfileViewController.m I implement the - (id)initWithId:(int)anIdentifier name:(NSString *)name selector to handle such mapping. I suppose opening URLs like x://profile/1/John Doe would invoke [[ProfileViewController alloc] initWithId:1 name:@"John Doe"], however, this seems not to be the case. The default TTWebController class gets called every time I open said URL.

Using single parameter开发者_JS百科, i.e something like x://profile/(initWithId:) does the right thing, which is to call [[ProfileViewController alloc] initWithId:1].

Did I miss something here? How to use multi-parameter mapping with Three20 and TTURLMap?


the problem is the that "x://profile/1/John Doe" isn't properly formatted as a URL. when you build the URL, try something like:

NSString *URL = [NSString stringWithFormat:@"x://profile/%d/%@", 1,
                 [@".." stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];

enjoy!

/mtr

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜