Post

Replies

Boosts

Views

Activity

update coredata value failed
I have two Entity first Entity attribute have "test1"(type is Integer16) second Entity attribute have "test2"(type is transformable) I try to test first Entity "add" "delete" "update" "search" It's all normal But I try to test second Entity Only "add" "delete" "search" is normal Data never be updated, and the value always stays at "add" value let mDelegate = UIApplication.shared.delegate as! AppDelegate let mContext = mDelegate.persistentContainer.viewContext var thisArray: NSMutableArray              let entity = NSEntityDescription.entity(forEntityName: "Scene", in: mContext)                  let request = NSFetchRequest<Scene>() request.entity = entity           do { let results:[AnyObject]? = try mContext.fetch(request)             for myTest in results as![Scene] { thisArray = myTest.chArrayValueStep1 as! NSMutableArray if thisArray[0] as! Int == 0x12 {                                thisArray[0] = 0x38 myTest.chArrayValueStep1 = thisArray mDelegate.saveContext() } } } catch { print("error") } How can I solve this problem? Thanks
1
0
321
Oct ’20