converting NSString to NSURL from a plist file
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:webStringU开发者_如何学GoRL];
[self loadURL:URL];
[self setURLToLoad:nil];
Where did i mess up?
NSString *filePath = @"/path/to/Info.plist";
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
NSString *urlString = [plistDict objectForKey:@"Link"];
NSURL *URL = [NSURL URLWithString:urlString];
[self loadURL:URL];
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.
精彩评论