Multi-parameter mapping with Three20 and TTURLMap

旧城冷巷雨未停 提交于 2019-12-21 21:24:32

问题


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, 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?


回答1:


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



来源:https://stackoverflow.com/questions/3182585/multi-parameter-mapping-with-three20-and-tturlmap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!