Reputation:
I saved a dictionary contents in server and from server it automatically converted to .txt
file how can i load that contents from url to another NSDictionary
?
I am using this code:
NSDictionary *Data = [[NSDictionary alloc]initWithContentsOfURL:[NSURL URLWithString:url]];
url is something like https://www.example.com/files/admin.txt
How do i load this to NSDictionary
?
I am now getting null values when i type the url in browser i get my file contents.
Upvotes: 3
Views: 804
Reputation:
I got the answer
NSDictionary *dict;
NSString *url=@"https://example.com/admin.txt";
NSMutableDictionary *str=[[NSMutableDictionary alloc]init];
str=[NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:url]];
NSMutableArray *a=[[NSMutableArray alloc]init];
[a addObject:[str objectForKey:@"Bookmarks"]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *Path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Bookmarks.plist"];
[a writeToFile:Path atomically:YES];
thanks for your all help
Upvotes: 2