UnsafePointer / ios-facade-example

This is a facade example with an iOS application using AFNetworking, TMCache, MagicalRecord and Mantle.
MIT License
69 stars 11 forks source link

Hi! I have a little problem. #1

Open xhzengAIB opened 10 years ago

xhzengAIB commented 10 years ago

Hi! @Ruenzuo @kevinwl02

Thank you for your example.

If i need to update a few fields, then how to do?

The RSS App, now update some articles to read. But MTLManagedObjectAdapter only provide inserting, not provide update.

So the question comes, we have one million data needs to be mark read, that do?

Jack

kevinwl02 commented 9 years ago

If I understand correctly you want to update data in Core Data. Just define a unique identifier for the entity you want to update both in the serializable entity and the managed object, then fetch the entity you want to modify with Magical Record using something like [YourManagedEntity MR_findFirstWithPredicate:], change its properties and save the context. Example:

[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
   NSPredicate *predicate = ...
   MOEntity *entity = [[MOEntity MR_findFirstWithPredicate:predicate] MR_inContext:localContext];
   entity.isRead = @1;
}

If what you want to do is update a very large number of entities in one go you may want to check NSBatchUpdateRequest.

Kevin

xhzengAIB commented 9 years ago

@kevinwl02 Thanks! but i don't know it is the transaction processing of CoreData?

Jack

kevinwl02 commented 9 years ago

Sorry I could not understand your question very well. The transactions are done through CoreData, MagicalRecord is a Core Data abstraction after all.