Note that there are some explanatory texts on larger screens.

plurals
  1. POMystery Key Value Coding Key
    text
    copied!<p>I'm attempting to load data from an undocumented API (OsiriX).</p> <p>Getting the NSManagedObject like this: <code>NSManagedObject *itemStudy = [[BrowserController databaseOutline] itemAtRow: [[BrowserController databaseOutline] selectedRow]];</code></p> <p>works just fine.</p> <p>But getting the NSManagedObject like this: <code>seriesArray = [_context executeFetchRequest:request error:&amp;error]; NSManagedObject *itemSeries = [seriesArray objectAtIndex:0];</code></p> <p>Generates an error when I call <code>[itemSeries valueForKey:@"type"]</code></p> <p><code>2010-05-27 11:04:48.178 rcOsirix[27712:7b03] Exception: [&lt;NSManagedObject 0xd30fd0&gt; valueForUndefinedKey:]: the entity Series is not key value coding-compliant for the key "type".</code></p> <p>This confuses me thoroughly. If I print the KVC values for itemSeries I get this list:</p> <pre><code>2010-05-27 11:04:48.167 rcOsirix[27712:7b03] KVC comment 2010-05-27 11:04:48.168 rcOsirix[27712:7b03] KVC date 2010-05-27 11:04:48.168 rcOsirix[27712:7b03] KVC dateAdded 2010-05-27 11:04:48.169 rcOsirix[27712:7b03] KVC dateOpened 2010-05-27 11:04:48.169 rcOsirix[27712:7b03] KVC displayStyle 2010-05-27 11:04:48.170 rcOsirix[27712:7b03] KVC id 2010-05-27 11:04:48.170 rcOsirix[27712:7b03] KVC modality 2010-05-27 11:04:48.170 rcOsirix[27712:7b03] KVC name 2010-05-27 11:04:48.171 rcOsirix[27712:7b03] KVC numberOfImages 2010-05-27 11:04:48.171 rcOsirix[27712:7b03] KVC numberOfKeyImages 2010-05-27 11:04:48.171 rcOsirix[27712:7b03] KVC rotationAngle 2010-05-27 11:04:48.172 rcOsirix[27712:7b03] KVC scale 2010-05-27 11:04:48.172 rcOsirix[27712:7b03] KVC seriesDICOMUID 2010-05-27 11:04:48.173 rcOsirix[27712:7b03] KVC seriesDescription 2010-05-27 11:04:48.173 rcOsirix[27712:7b03] KVC seriesInstanceUID 2010-05-27 11:04:48.173 rcOsirix[27712:7b03] KVC seriesSOPClassUID 2010-05-27 11:04:48.174 rcOsirix[27712:7b03] KVC stateText 2010-05-27 11:04:48.174 rcOsirix[27712:7b03] KVC thumbnail 2010-05-27 11:04:48.174 rcOsirix[27712:7b03] KVC windowLevel 2010-05-27 11:04:48.175 rcOsirix[27712:7b03] KVC windowWidth 2010-05-27 11:04:48.175 rcOsirix[27712:7b03] KVC xFlipped 2010-05-27 11:04:48.176 rcOsirix[27712:7b03] KVC xOffset 2010-05-27 11:04:48.176 rcOsirix[27712:7b03] KVC yFlipped 2010-05-27 11:04:48.176 rcOsirix[27712:7b03] KVC yOffset 2010-05-27 11:04:48.177 rcOsirix[27712:7b03] KVC mountedVolume 2010-05-27 11:04:48.177 rcOsirix[27712:7b03] KVC study 2010-05-27 11:04:48.178 rcOsirix[27712:7b03] KVC images </code></pre> <p>The KVC for itemStudy is this:</p> <pre><code>2010-05-27 10:46:40.336 OsiriX[27266:a0f] KVC accessionNumber 2010-05-27 10:46:40.336 OsiriX[27266:a0f] KVC comment 2010-05-27 10:46:40.336 OsiriX[27266:a0f] KVC date 2010-05-27 10:46:40.336 OsiriX[27266:a0f] KVC dateAdded 2010-05-27 10:46:40.336 OsiriX[27266:a0f] KVC dateOfBirth 2010-05-27 10:46:40.336 OsiriX[27266:a0f] KVC dateOpened 2010-05-27 10:46:40.337 OsiriX[27266:a0f] KVC dictateURL 2010-05-27 10:46:40.337 OsiriX[27266:a0f] KVC expanded 2010-05-27 10:46:40.337 OsiriX[27266:a0f] KVC hasDICOM 2010-05-27 10:46:40.337 OsiriX[27266:a0f] KVC id 2010-05-27 10:46:40.337 OsiriX[27266:a0f] KVC institutionName 2010-05-27 10:46:40.337 OsiriX[27266:a0f] KVC lockedStudy 2010-05-27 10:46:40.337 OsiriX[27266:a0f] KVC modality 2010-05-27 10:46:40.338 OsiriX[27266:a0f] KVC name 2010-05-27 10:46:40.338 OsiriX[27266:a0f] KVC numberOfImages 2010-05-27 10:46:40.338 OsiriX[27266:a0f] KVC patientID 2010-05-27 10:46:40.338 OsiriX[27266:a0f] KVC patientSex 2010-05-27 10:46:40.338 OsiriX[27266:a0f] KVC patientUID 2010-05-27 10:46:40.338 OsiriX[27266:a0f] KVC performingPhysician 2010-05-27 10:46:40.339 OsiriX[27266:a0f] KVC referringPhysician 2010-05-27 10:46:40.339 OsiriX[27266:a0f] KVC reportURL 2010-05-27 10:46:40.339 OsiriX[27266:a0f] KVC stateText 2010-05-27 10:46:40.339 OsiriX[27266:a0f] KVC studyInstanceUID 2010-05-27 10:46:40.339 OsiriX[27266:a0f] KVC studyName 2010-05-27 10:46:40.339 OsiriX[27266:a0f] KVC windowsState 2010-05-27 10:46:40.339 OsiriX[27266:a0f] KVC albums 2010-05-27 10:46:40.340 OsiriX[27266:a0f] KVC series </code></pre> <p>If I use code:</p> <pre><code>NSDictionary *props = [[item entity] propertiesByName]; for (NSString *s in [props allKeys]) { NSLog(@"KVC %@", s); } </code></pre> <p>Yet <code>itemStudy</code> throws no error if I call <code>[itemStudy valueForKey:@"type"]</code> when it should because there's no KVC for <code>@"type"</code>!!! </p> <p>Granted, the objects are different but neither of them contain the key <code>@"type"</code> and they both should throw errors, yet the Osirix code Tests for both conditions:</p> <pre><code>if ([[item valueForKey:@"type"] isEqualToString:@"Series"]) { ... } if ([[item valueForKey:@"type"] isEqualToString:@"Study"]) { ... } </code></pre> <p>And throws no errors. Yet when I load an <code>NSManagedObject</code> of the same exact model and entity <code>@"Series"</code> it throws the 'no key value' when passed into the conditions above.</p> <p>Am I missing something? Both the <code>superentity</code> and <code>subentities</code> of itemSeries and itemStudy are <code>nil</code> so they don't inherit from something that has KVC <code>@"type"</code>.</p> <p>I'm totally at a loss as to explain what is going on.</p> <p>--- EDIT ---</p> <p>I know no one can explain what is going on... but maybe where to start looking? How would itemStudy have the extra KVC @"type" that doesn't show up in it's property list?</p> <p>Thank you for your assistance,</p> <p>-Stephen</p> <p>--- EDIT ---</p> <p>OK so after digging around more I think this is a CoreData misunderstanding on my part.</p> <p>The API includes the classes <code>DicomSeries</code> and <code>DicomStudy</code> which are subclasses of NSManagedObject and are included in the xcdatamodel file.</p> <p>I am including the xcdatamodel file as a "compiled source" and DicomSeries.h and DicomStudy.h</p> <p><code>DicomSeries</code> and <code>DicomStudy</code> are "hard-coded" with:</p> <pre><code>- (NSString*) type { return @"Series"; } </code></pre> <p>But the objects I create for <code>itemStudy</code> Never call this method. Objects created like <code>itemStudy</code> above, do. Even <code>DicomSeries</code> objects called within the main program do. But not ones that I make with the fetch request from the same database.</p> <p>Even if I do:</p> <pre><code>DicomSeries *itemSeries = [_context executeFetchRequest:request] </code></pre> <p>Where the request has entity <code>@"Series"</code> which is of Class <code>DicomSeries</code> so it SHOULD respond to:</p> <pre><code>[itemSeries valueForKey:@"type"]; </code></pre> <p>but it doesn't.</p> <p>I feel like there's a big giant gap of CoreData I'm missing. My <code>NSManagedObjectModel</code> that I'm using in my persistent Store Coordinator and my context has Entities for <code>Series</code> and is of <code>managedObjectClassName</code> <code>DicomSeries</code> so...</p> <p>yeah.</p> <p>lol, wut?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload