开发者

converting NSString to NSURL from a plist file

开发者 https://www.devze.com 2023-02-24 12:45 出处:网络
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'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.

0

精彩评论

暂无评论...
验证码 换一张
取 消