我不知道如何从一个字符串数组(parentRootItems),我得到这个代码的对象:
NSArray *parentRootItems = [pFolder rootItems];
NSLog(@"parentRootItems %@", [parentRootItems description]);
NSString *keyPath = [NSString stringWithFormat:@"@distinctUnionOfObjects.%@", metadata.lookupItemsKeyPath];
NSLog(@"keyPath %@", keyPath);
NSArray *managedItems = [parentRootItems valueForKeyPath:keyPath];
NSLog(@"managedItems %@", [managedItems description]);
由于
输出
parentRootItems (Self-Inflicted Wounds / Rebirth)
(Self-Inflicted Wounds / Rebirth)
...
keyPath @distinctUnionOfObjects.Series
managedItems (
<CBSeries: 0x1ddf3c0> (entity: Series; id: 0x1ddf260 <x-coredata://2B6F6719-9BCB-4C5C-B027-0DE2C7C1910C/Series/p350> ; data: {
ClzID = 37268;
Comics = "<relationship fault: 0x1de3790 'Comics'>";
Complete = 0;
DisplayName = Annihilators;
Frequency = nil;
ISSN = nil;
Image = nil;
Name = nil;
NumIssues = 0;
SortName = Annihilators;
Stories = "<relationship fault: 0x1de39c0 'Stories'>";
The = nil;
URL = nil;
UniqueID = 1;
}),
<CBSeries: 0x1dd2940> (entity: Series; id: 0x1db4b60 <x-coredata://2B6F6719-9BCB-4C5C-B027-0DE2C7C1910C/Series/p354> ; data: {
ClzID = 3856;
Comics = "<relationship fault: 0x1de4230 'Comics'>";
Complete = 0;
DisplayName = Futurama;
Frequency = nil;
ISSN = nil;
Image = nil;
Name = nil;
NumIssues = 0;
SortName = Futurama;
Stories = "<relationship fault: 0x1de4510 'Stories'>";
The = nil;
URL = nil;
UniqueID = 9;
}),
...
答案 0 :(得分:0)
parentRootItems
不是字符串数组。通过它的外观,它是一个托管对象数组,每个托管对象都有.Series
属性,指向Series
实体的另一个托管对象。
您将返回一个数组,其中包含Series
中对象使用的每个parentRootItems
实体,并删除了所有重复项。
要更清楚地了解parentRootItems
中的内容,请使用以下日志消息,而不是您当前正在执行的description
:
NSLog(@"Parent root items: %@",parentRootItems);