gpt4 book ai didi

ios - 如何在 xmppGroupCoreDataStorageObject 中保存和获取?

转载 作者:行者123 更新时间:2023-11-28 06:28:38 25 4
gpt4 key购买 nike

使用 xmpp-messenger-ios,我创建了组并设置了它的配置并将用户添加到其中,然后我想将组添加到 xmppGroupCoreDataStorageObject存储以将其列到 OpenChatViewController TableView 中。

我如何将组数据保存到 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;

最佳答案

那么,您正在尝试将消息发送到无法响应它的对象。
查看您的异常日志:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString managedObjectContext]: unrecognized selector sent to instance 0x7fdf8c545e50'***  

managedObjectContext 消息已发送到 NSString 类的实例。
当然,它无法响应它,您正在崩溃。

关于ios - 如何在 xmppGroupCoreDataStorageObject 中保存和获取?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41038176/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com