我正在关注this教程并在我的应用程序委托(delegate)中声明以下映射:
[map from:@"x://profile/(initWithId:)/(name:)" toViewController:[ProfileViewController class]];
[map from:@"*" toViewController:[TTWebController class]];
在 ProfileViewController.m
中,我实现了 - (id)initWithId:(int)anIdentifier name:(NSString *)name
选择器来处理此类映射。我想打开像 x://profile/1/John Doe
这样的 URL 会调用 [[ProfileViewController alloc] initWithId:1 name:@"John Doe"]
,但是,情况似乎并非如此。每次我打开所述 URL 时,都会调用默认的 TTWebController 类。
使用单个参数,即类似 x://profile/(initWithId:)
的方法是正确的,即调用 [[ProfileViewController alloc] initWithId:1]
.
我是不是错过了什么?如何使用 Three20 和 TTURLMap 进行多参数映射?
最佳答案
问题是“x://profile/1/John Doe”的 URL 格式不正确。当您构建 URL 时,请尝试以下操作:
NSString *URL = [NSString stringWithFormat:@"x://profile/%d/%@", 1,
[@".." stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
享受吧!
/地铁
关于iphone - 使用 Three20 和 TTURLMap 进行多参数映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3182585/