私が解析している JSON は、ここで「編集済み」で見つけることができます。
この JSON から、通知とデバイスを除くすべてのオブジェクトを正しく取得できます。「deviceId」を含むデバイス ディクショナリの配列を取得できず、多くの問題が発生しています。私のコードは今このようになります
dispatch_async(kBgQueue, ^{
NSData* data = [NSData dataWithContentsOfURL:
iViuListOfCustomersURL];
[self performSelectorOnMainThread:@selector(fetchedData:)
withObject:data waitUntilDone:NO];
});
- (void) fetchedData:(NSData *)responseData {
NSError* error;
NSDictionary* json;
json = [NSJSONSerialization
JSONObjectWithData:responseData // 1
options:kNilOptions
error:&error];
NSArray* customers = json;
for(int i = 0; i < customers.count ; i++){
NSDictionary *customer = [customers objectAtIndex:i];
cmsServer = [customer objectForKey:@"cmsServer"];
iconUrl = [NSURL URLWithString:[customer objectForKey:@"iconUrl"]];
wideLogo = [customer objectForKey:@"wideLogo"];
customerNo = [NSNumber numberWithInt:[[customer objectForKey:@"customerNo"] intValue]];
placeName = [customer objectForKey:@"placeName"];
distance = [NSNumber numberWithFloat:[[customer objectForKey:@"distance"] floatValue]];
placeId = [NSNumber numberWithInt:[[customer objectForKey:@"placeId"] intValue]];
address = [customer objectForKey:@"address"];
cmsName = [customer objectForKey:@"cmsName"];
hasLocations = [NSNumber numberWithInt:[[customer objectForKey:@"hasLocations"]intValue]];
isFavorite = [NSNumber numberWithInt:[[customer objectForKey:@"isFavorite"] intValue]];
longitude = [NSNumber numberWithFloat:[[customer objectForKey:@"longitude"] floatValue]];
latitude = [NSNumber numberWithFloat:[[customer objectForKey:@"latitude"] floatValue]];
hasArtifacts = [NSNumber numberWithInt:[[customer objectForKey:@"hasArtifacts"]intValue]];
// I have tried a number of things and this was what I had for the last try.
devices = [NSArray arrayWithObject:[customer objectForKey:@"devices"]];
NSLog(@"%@",devices.count);
}
}
私は Objective-C に比較的慣れておらず、自分でこれを理解したいと思っていましたが、この問題に多くの時間を費やしたため、これらのデバイス ID なしでは続行できません。
ありがとうございました!