インスタンスで基本クラス メソッドを呼び出すと、「認識されないセレクター」例外が発生し、何が問題なのかわかりません。
次のように Form というオブジェクトがあります。
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "HPSDbBase.h"
@interface Form : HPSDbBase
@end
Form の基本クラスは次のようになります。
#import <CoreData/CoreData.h>
@interface HPSDbBase : NSManagedObject
@property (nonatomic, retain) NSString * id;
@property (nonatomic, retain) NSString * json;
-(id)getJSONElement:(NSString*)key;
@end
次に、次のように、View Controller メソッド内で Form オブジェクトを使用してみます。
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:&error];
for (int i=0;i<arrayOfForms.count;i++)
{
    Form* dbForm = [arrayOfForms objectAtIndex:i];
    NSLog(@"Form.json=%@",dbForm.json); // this works
    NSString* wwwww = (Form*)[dbForm getJSONElement:@"test"]; // exception here
}
例外は次のとおりです。
-[NSManagedObject getJSONElement:]: unrecognized selector sent to instance 0x8290940
誰かが私が間違っていることを見ることができますか?
どうもありがとう!
編集1
以下は、HPSDbBase の実装です。
#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: &e];
    NSDictionary *jsonDictionary = (NSDictionary *)jsonObject;
    id rc = [jsonDictionary objectForKey:key];
    return rc;
}
@end