2016-06-11 65 views
0

無法弄清楚爲什麼我得到這個錯誤。領域目標C:'RLMObject'沒有可見的@interface聲明選擇器'createOrUpdateInRealm:withValue:'

爲 'RLMObject' 不可見@interface聲明選擇 'createOrUpdateInRealm:withValue:'

我已經包含了領域/ Realm.h頭

定義我RLMObject以這種方式

Class aClass = NSClassFromString(modelName); 
RLMObject *m = [[aClass alloc] init]; 

然後我創建一個NSMutableDictionary來包含我想要在RLMObject上部分更新的值。

NSMutableDictionary *updateValues = [[NSMutableDictionary alloc] init]; 

然後我打電話createOrUpdateInRealm:withValue:在m個

[m createOrUpdateInRealm:realm withValue:updateValues]; 

但我得到的錯誤。我不知道爲什麼會發生這種情況?

回答

0

+createOrUpdateInRealm:withValue:RLMObject的一類方法,不是實例方法。這意味着你需要直接調用它放在你的子類,而不是你的子類的實例:

[MyClass createOrUpdateInRealm:realm withValue:dictionary]; 
1

createOrUpdateInRealm:withValue:應該在你的子類調用,而不是一個實例。

你應該使用這樣的:

CustomObject *myCustomObject = [CustomObject createOrUpdateInRealm:realm withValue:dictionary]; 

其中CustomObjectRLMObject一個子類。

相關問題