title: Managed Object in Core Data entity causing "is not key value coding-compliant for key" error
body: <p>I'm pretty new to Core Data, and objective-c.  I have been up and down the Core Data documentation, and don't know what I'm doing wrong here.</p>
  
  <p>At runtime, I'm getting the following error when adding the NSManagedObject "ReportItem" to the NSMutableSet "reports" in the NSManagedObject "RoomItem": <code>NSUnknownKeyException', reason: '[&lt;RoomItem 0x747c850&gt; valueForUndefinedKey:]: the entity RoomItem is not key value coding-compliant for the key "reports"</code></p>
  
  <p><strong>The error is occurring inside of the "RoomList" store class in the "creatReportForRoom" method below, which is called upon viewWillDisapear in the UIViewController where the relevant data is entered:</strong></p>
  
  <pre><code>- (ReportItem *)creatReportForRoom:(RoomItem *)currentRoom Report:(ReportItem *)report
  {
      NSDate *dateCreated = [NSDate date];
  
      ReportItem *detailItem = [NSEntityDescription insertNewObjectForEntityForName:@"ReportItem" inManagedObjectContext:context];
  
      [detailItem setDateReportCreated:dateCreated];
  
      NSMutableSet *reports = [currentRoom mutableSetValueForKey:@"reports"];
  
      [reports addObject:detailItem];  //error is occurring at this line
  
      [allReports addObject:detailItem];
      return detailItem;
  }
  </code></pre>
  
  <p><strong>The "RoomItem" NSManagedObject files are here:</strong></p>
  
  <p>RoomItem.h</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  #import &lt;CoreData/CoreData.h&gt;
  
  @interface RoomItem : NSManagedObject
  
  @property (nonatomic, strong) NSString *building;
  @property (nonatomic, strong) NSString *room;
  @property (nonatomic, retain) NSString *imageKey;
  @property (nonatomic, retain) UIImage *buildingImage;
  @property (nonatomic, strong) UIImage *buildingThumbnail;
  @property (nonatomic, strong) NSData *buildingThumbnailData;
  @property (nonatomic) double objectIndex;
  @property (nonatomic, strong) NSDate *dateCreated;
  
  @property (nonatomic, retain) NSMutableSet *reports;
  
  @end
  </code></pre>
  
  <p>RoomItem.m</p>
  
  <pre><code>#import "RoomItem.h"
  
  @implementation RoomItem
  
  @dynamic building, buildingThumbnail, buildingThumbnailData, objectIndex, room, dateCreated, imageKey, buildingImage, reports;
  
  @end
  </code></pre>
  
  <p><strong>I've including the "createItem" method were the RoomItem is created and stored, in case I'm doing something wrong there:</strong></p>
  
  <pre><code>- (RoomItem *)createItem
  {
      double order;
  
      //create new roomItem
      //tracks what number item it's creating
      if ([allItems count] == 0) {
          order = 1.0;
      }
      else
      {
          order = [[allItems lastObject] objectIndex] + 1;
      }
      NSLog(@"Adding after %d items, order = %.2f", [allItems count], order);
  
      RoomItem *detailItem = [NSEntityDescription insertNewObjectForEntityForName:@"RoomItem"
                                                      inManagedObjectContext:context];
      [detailItem setObjectIndex:order];
      [detailItem setDateCreated:[NSDate date]];
  
      [allItems addObject:detailItem];
  
      return detailItem;
  }
  </code></pre>
  
  <p><strong>Data Model with relationships:</strong>
  <img src="https://i.stack.imgur.com/zcW90.png" alt="enter image description here"></p>
  
  <p><strong>Relationship Diagram:</strong>
  <img src="https://i.stack.imgur.com/bjVa7.png" alt="enter image description here"></p>
  
  <p>Any advice on fixing this problem would be hugely appreciated.  Please let me know if there's anything I failed to include that might help.</p>
  
  <p>Thanks!</p>