0
取如GrandChild感謝您對您的幫助提前。核心數據從父
我能夠從父獲取子實體,如下面的代碼所示,但我想不出如何獲取基於一定的兒童在父母的孫子。
如何在添加或更改我現有的代碼來獲得基於兒童的屬性了孫子的價值觀?
NSMutableArray *createdMutable = [[NSMutableArray alloc]init];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc]initWithKey:@"randomAttribute" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:&sortDescriptor count:2];
NSMutableArray *sortedResults = [[NSMutableArray alloc] initWithArray: [parentEntity.parentToChild allObjects]];
[sortedResults sortUsingDescriptors:sortDescriptors];
[sortedResults valueForKey:@"randomAttribute"];
NSString *addedCreatedMutable;
for (int i = 0; [sortedResults count] > i; i++) {
addedCreatedMutable = [[sortedResults valueForKey:@"randomAttribute"]objectAtIndex:i];
addedCreatedMutable = [addedCreatedMutable stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([createdMutable containsObject:addedCreatedMutable]) {
}else{
[createdMutable addObject:addedCreatedMutable];
}