Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用iPhone的Coredata无法正确检索关系中的对象_Iphone_Objective C_Core Data - Fatal编程技术网

使用iPhone的Coredata无法正确检索关系中的对象

使用iPhone的Coredata无法正确检索关系中的对象,iphone,objective-c,core-data,Iphone,Objective C,Core Data,有人知道这个班的学生做什么吗 好的,我正在这样做:我在两个日期之间获取对象计划的属性description、date和personaldata,它也与对象操作符有关系,只有一个方向是single Schedule->Operator。fetch检索数据,但当我想访问诸如“name”之类的操作符的属性时,应用程序崩溃并告诉我_NSObjectID_48_1不响应选择器。当然,我在提取期间启用了这一行: [request setRelationshipKeyPathsForPrefetching:[

有人知道这个班的学生做什么吗

好的,我正在这样做:我在两个日期之间获取对象计划的属性description、date和personaldata,它也与对象操作符有关系,只有一个方向是single Schedule->Operator。fetch检索数据,但当我想访问诸如“name”之类的操作符的属性时,应用程序崩溃并告诉我_NSObjectID_48_1不响应选择器。当然,我在提取期间启用了这一行:

[request setRelationshipKeyPathsForPrefetching:[NSArray arrayWithObject:entityToPrefetch]];
这是如何设置要获取的属性,而不是整个Schedule对象。此外,在检索数据时,它被设置为NSDictionaryResultType,因为否则它会抱怨无法正确获取数据

NSEntityDescription *entity = [NSEntityDescription entityForName:@"Operator"
                                                      inManagedObjectContext:[AppDelegate managedObjectContext]];
            NSDictionary *relationship = [entity relationshipsByName];
            NSDictionary *entityProperties = [entity propertiesByName];
            NSArray *properties = [[NSArray alloc] initWithObjects:[entityProperties objectForKey:@"description"],
                                   [entityProperties objectForKey:@"date"],
                                   [relationship objectForKey:@"personalData"],nil];

            NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date >= %@ && \
                                                                        date <= %@",
                                      [dateArray objectAtIndex:0],
                                      [dateArray lastObject]];
schedArray=executefetch

SLog(schedArray);
    SLog([schedArray objectAtIndex:0]);
    SLog([[schedArray objectAtIndex:0] objectForKey:@"employee"]);
    VoicePickOperators *employee = (VoicePickOperators *)[[schedArray objectAtIndex:0] objectForKey:@"employee"];
    SLog(employee);
    SLog([employee name]); <<------ Problem, I am trying to access an attribute that should be there but instead is of the type __NSObjectID_48_1
    SLog([employee description]);
有人知道这是怎么回事吗


谢谢

NSObjectID是NSManagedObjectID。您确定使用的是dictionary结果类型吗?当我请求获取数据时,在执行此操作之前,我设置了其标志:[request setResultType:NSDictionaryResultType];我使用的解决方案是将所有对象作为NSArrayResultType返回,并从中丢弃我不需要的元素,但这并不是解决此问题的正确方法。这样做,我无法设置我想要的NSArrayof属性。没有NSArrayResultType这样的东西。@Invoke,您找到解决此问题的方法了吗?我也面临同样的问题。