使用xmpp-messenger-ios
,我已經創建了該組並設置了它的配置並添加了用戶,然後我想將該組添加到xmppGroupCoreDataStorageObject
存儲中以將其列入OpenChatViewController表視圖。如何保存和獲取xmppGroupCoreDataStorageObject?
如何我節省了組數據到xmppGroupCoreDataStorageObject:
public class func addUserInCoreData(jid:String, users: Set<NSObject>) {
let moc = OneRoster.sharedInstance.managedObjectContext_roster() as NSManagedObjectContext?
let entity = NSEntityDescription.entityForName("XMPPGroupCoreDataStorageObject", inManagedObjectContext: moc!)
let person = NSManagedObject(entity: entity!, insertIntoManagedObjectContext: moc!)
person.setValue(jid, forKey: "name")
person.setValue(users, forKey: "users") // Code breaks here.
print(moc.debugDescription)
do{
try moc?.save()
let sucess = XMPPGroupCoreDataStorageObject.insertGroupName(jid, inManagedObjectContext: moc)
print(sucess)
}
catch let error{
print(error)
}
}
遭遇異常:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString managedObjectContext]: unrecognized selector sent to instance 0x7fdf8c545e50'***
這裏是框架實現:
@property (nonatomic, strong) NSString * name;
@property (nonatomic, strong) NSSet* users;
兄你能幫我解決這個問題嗎?https://stackoverflow.com/questions/44172852/how-to-parse-xmppmessage-element-attribute-and-node-in-xmppframework-with-swif? –