1
我创建一个NSArray从CoreData取像这样:我如何通过自定义的一个NSArray循环对象
self.farSiman = [self.managedObjectContext executeFetchRequest:request error:&error];
在的tableview我用这个代码,让我的自定义对象:
Holiday *holiday = [self.dates objectAtIndex:indexPath.row];
cell.nameLabel.text = holiday.name;
但是,我现在在另一个viewcontroller,试图绘制一个mapkit上的数据,所以在绘图方法我原来这样做是因为我从一个plist文件中获取数组。但现在我的阵列是定制的假日的对象,因此这不工作了:
NSLog(@"dictionary is %@", self.farSiman);
for (NSDictionary * dict in self.farSiman) {
NSNumber * latitude = [dict objectForKey:@"latitude"];
NSNumber * longitude = [dict objectForKey:@"longitude"];
NSString * storeDescription = [dict objectForKey:@"name"];
NSString * address = [dict objectForKey:@"address"];
NSLog(@"logging location %@", storeDescription);
CLLocationCoordinate2D coordinate;
coordinate.latitude = latitude.doubleValue;
coordinate.longitude = longitude.doubleValue;
MyLocation *annotation = [[MyLocation alloc] initWithName:storeDescription address:address coordinate:coordinate];
[_mapView addAnnotation:annotation];
}
我的字典日志打印出这一点:
dictionary is (
"<Holiday: 0x838bc80> (entity: Holiday; id: 0x838ca60 <x-coredata://E41B0CCD-2F03-4C4F-B054-18537096771C/Holiday/p1> ; data: <fault>)",
"<Holiday: 0x838e330> (entity: Holiday; id: 0x838ca70 <x-coredata://E41B0CCD-2F03-4C4F-B054-18537096771C/Holiday/p2> ; data: <fault>)"
这意味着它的节日对象的数组。
如何获取我的for循环中的每个对象,因为我使用枚举而不是传统的for i = 0; i<count; i++
?