How do you update a CoreData entry that has already been saved in Swift?

后端 未结 14 2701
有刺的猬
有刺的猬 2020-11-30 00:55

I\'m not sure what I\'m doing wrong here, but when I save the first time into coredata, it works just fine. When I try to overwrite that, it doesn\'t.

func t         


        
14条回答
  •  庸人自扰
    2020-11-30 01:41

    There's a new feature called Batch Updates.

    I think this article will help you:

    http://www.bignerdranch.com/blog/new-in-core-data-and-ios-8-batch-updating/

    Basicly what you do is use the NSBatchUpdateRequest instead of NSFetchRequest, filter the results with NSPredicate, change the value in the results, and save the data.

    Another tutorial in swift:

    http://code.tutsplus.com/tutorials/ios-8-core-data-and-batch-updates--cms-22164

提交回复
热议问题