//------------------------------
// JSONを読み込む
//------------------------------
NSError *error0 = nil;
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource:@"local" ofType:@"json"];
NSString *jsonString = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error: &error0];
NSData *jsonData = [jsonString dataUsingEncoding:NSUnicodeStringEncoding];
if(error0){NSLog(@"よみこみえらー");}
//------------------------------
// NSArray に変換
//------------------------------
NSError *error1 = nil;
NSArray *array = [NSJSONSerialization JSONObjectWithData:jsonData
options:NSJSONReadingAllowFragments
error:&error1];
if(error1){NSLog(@"ぱーすえらー");}
More than 5 years have passed since last update.
[objc][memo] BundleのJSONを読み込んでNSArrayにする
Last updated at Posted at 2014-04-09
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme