Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse data from json local file using AFNetworking

Is it possible to parse data from a local json file ,using AFNetworking instead of SBJSON?

like image 971
Nassif Avatar asked Nov 28 '22 02:11

Nassif


1 Answers

You don't need to use AFNetworking for local JSON. You won't have any network related advantage in local files.

NSString *filePath = [[NSBundle mainBundle] pathForResource:jsonFileName ofType:@"json"];
NSData *JSONData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:nil];
NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil];

Now use jsonDictionary as per your need.

like image 126
Bishal Ghimire Avatar answered Dec 20 '22 00:12

Bishal Ghimire