我有以下一段代码。
-(NSDictionary *)getPlayers
{
NSManagedObjectContext *context = self.genkDatabase.managedObjectContext;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Team"
inManagedObjectContext:context];
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"position ==[c] %@", @"Doelman"];
[fetchRequest setEntity:entity];
NSError *error;
NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
if (fetchedObjects == nil) {
// Handle the error.
}else
for (Team *info in fetchedObjects) {
[_photos setObject:info.image forKey:@"player_imgUrl"];
[_photos setObject:info.name forKey:@"player_name"];
}
NSLog(@"%@",_photos);
return _photos;
但出于某种原因,我的 NSLog 总是返回 (null)。但是当我这样做时
[_photos setObject:info.image forKey:@"player_imgUrl"];
[_photos setObject:info.name forKey:@"player_name"];
NSLog(@"name: %@",info.name );
NSLog(@"url: %@",info.image );
它会返回正确的数据。
有人可以帮忙吗?
亲切的问候。