将 NSString 从 plist 文件转换为 NSURL
我一直在尝试将 plist 文件中的字符串获取到 webview 的 NSURL 中。 要么我得到“nil”作为返回值,要么什么都没有(控制台中没有错误)
我知道这段代码有问题,但我无法查明它在哪里。
NSString *filePath = @"/path/to/Info.plist";
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
NSString *value;
value = [plistDict objectForKey:@"Link"];
NSString *webStringURL = [value stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *URL = [NSURL URLWithString:webStringURL];
[self loadURL:URL];
[self setURLToLoad:nil];
我哪里搞砸了?
I've been trying to get a string from a plist file into a NSURL for webview.
Either i get 'nil' for the returned value, or nothing (no error in console)
I know something's wrong with this code, but i can't pinpoint it where.
NSString *filePath = @"/path/to/Info.plist";
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
NSString *value;
value = [plistDict objectForKey:@"Link"];
NSString *webStringURL = [value stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *URL = [NSURL URLWithString:webStringURL];
[self loadURL:URL];
[self setURLToLoad:nil];
Where did i mess up?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了更好地理解,请参阅此网站:
http://iphonesdevsdk.blogspot.com/2011/ 04/plist.html
它可以帮助您轻松使用plist。
For your better understanding refer to this site:
http://iphonesdevsdk.blogspot.com/2011/04/plist.html
It may help you in using plist in easy way.