【发布时间】:2010-12-31 04:24:57
【问题描述】:
这可能很容易,但我似乎不明白为什么 URLWithString: 在这里返回 nil。
//localisationName is a arbitrary string here
NSString* webName = [localisationName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString* stringURL = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@,Montréal,Communauté-Urbaine-de-Montréal,Québec,Canadae&output=csv&oe=utf8&sensor=false&key=", webName];
NSURL* url = [NSURL URLWithString:stringURL];
【问题讨论】:
-
在您致电
stringWithFormat:之前,webName的值是多少?那么,在您调用URLWithString:之前,stringURL的值是多少?使用NSLog()逐步打印出来,或者设置断点并检查设置的值。
标签: iphone objective-c url nsstring nsurl