新しいオブジェクトを CoreData データストアに正しく追加する方法を知りたいです。次のコードは機能しますが、新しい NSString と新しい NSNumber を使用して値を設定する必要があることに少し驚いています。それに加えて、私のコードがメモリリークにつながるのではないかと心配しています。
let ed = NSEntityDescription.InsertNewObjectForEntityForName("Document", context)
ed.SetValueForKey(new NSString("title"), new NSString("title"))
ed.SetValueForKey(new NSString("file"), new NSString("file"))
ed.SetValueForKey(new NSString("base_name"), new NSString("base_name"))
ed.SetValueForKey(new NSNumber(123), new NSString("question_count"))
ed.SetValueForKey(new NSString("revision"), new NSString("revision"))
ed.SetValueForKey(new NSString("valid"), new NSString("valid"))
let error = context.Save()