title: Unrecognized selector for NSManagedObject base class
body: <p>I am getting an 'unrecognised selector' exception when calling a base-class method on an instance and can't see what the problem is.</p>
  
  <p>I have an object called Form as follows:</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  #import &lt;CoreData/CoreData.h&gt;
  #import "HPSDbBase.h"
  
  @interface Form : HPSDbBase
  
  @end
  </code></pre>
  
  <p>The base class for Form looks like this:</p>
  
  <pre><code>#import &lt;CoreData/CoreData.h&gt;
  
  @interface HPSDbBase : NSManagedObject
  
  @property (nonatomic, retain) NSString * id;
  @property (nonatomic, retain) NSString * json;
  
  -(id)getJSONElement:(NSString*)key;
  
  @end
  </code></pre>
  
  <p>I then try using the Form object within a view controller method as follows:</p>
  
  <pre><code>HPSAppDelegate* appDelegate = [[UIApplication sharedApplication] delegate];
  
  NSError* error = nil;
  NSFetchRequest * request = [[NSFetchRequest alloc] init];
  
  [request setEntity:[NSEntityDescription entityForName:@"Form" inManagedObjectContext:appDelegate.managedObjectContext]];
  
  NSArray* arrayOfForms = [appDelegate.managedObjectContext executeFetchRequest:request error:&amp;error];
  
  for (int i=0;i&lt;arrayOfForms.count;i++)
  {
  
      Form* dbForm = [arrayOfForms objectAtIndex:i];
  
      NSLog(@"Form.json=%@",dbForm.json); // this works
  
      NSString* wwwww = (Form*)[dbForm getJSONElement:@"test"]; // exception here
  
  }
  </code></pre>
  
  <p>The exception is:</p>
  
  <pre><code>-[NSManagedObject getJSONElement:]: unrecognized selector sent to instance 0x8290940
  </code></pre>
  
  <p>Can anyone see what I'm doing wrong?</p>
  
  <p>Thanks a million!</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>Here is the implementation for HPSDbBase:</p>
  
  <pre><code>#import "HPSDbBase.h"
  
  @implementation HPSDbBase
  
  @dynamic id;
  @dynamic json;
  
  
  -(id)getJSONElement:(NSString*)key
  {
      NSData *jsonData = [[self json] dataUsingEncoding:NSUTF8StringEncoding];
  
      NSError *e = nil;
  
      id jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData options: NSJSONReadingMutableContainers error: &amp;e];
      NSDictionary *jsonDictionary = (NSDictionary *)jsonObject;
  
      id rc = [jsonDictionary objectForKey:key];
  
      return rc;
  }
  
  @end 
  </code></pre>