I don’t get how from an array of Strings (parentRootItems), I do get objects with this code:
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]);
Thanks
Output
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;
}),
...
parentRootItemsisn’t an array of strings. By the looks of this it is an array of managed objects, which each have a.Seriesattribute, which points to another managed object, ofSeriesentity.You are getting back an array containing each
Seriesentity used by the objects inparentRootItems, with any duplicates removed.To see more clearly what is in
parentRootItems, use the following log message instead of thedescriptionwhich is what you are currently doing: