Comments (6)
call [[NSManagedObjectContext defaultContext] save];
from magicalrecord.
I know I can always grab the managed object context and save. Doing this feels contrary to the whole point of this type of library, which in a lot of ways is trying to hide the verbosity of the Core Data API. Does it make more sense to perform a performSaveDataOperationWithBlock?
from magicalrecord.
Or, you can use the one in your new entity:
MyEntity *m = [MyEntitty createEntity];
[m.managedObjectContext save];
Remember, Core Data is an object graph, and is a little different from other "ORM"s. The Managed Object Context manages saves, not the entities themselves.
from magicalrecord.
@casademora That makes sense. I guess I need to get used to Core Data, spent to much time with RoR...
from magicalrecord.
The performSaveOperationWithBlock is an attempt to hide the nasty setup require when saving stuff to another context, and then syncing it up with the main context. This method is also used when performing saves in the background.
I have resisted putting a save method on the entity objects themselves because it'll never be saving only that object...since saves are always performed on the context containing many entities, you could also be persisting your deletes, updates and insert for other changes.
That said, I also tried to name this library to reflect the subset of the Active Record pattern that applies, namely the fetching part. I do plan, however, to change the name of the library in the near future so that there is less confusion with the Active Record pattern.
from magicalrecord.
Yes, it would be misleading to have an instance method on an entity for save or commit. In that light it makes more sense to use the [[NSManagedObjectContext defaultContext] save] call as it clearly shows that the action will save the entire context. Makes no difference in effect but shows the devs not just the intent but what will actually happen.
from magicalrecord.
Related Issues (20)
- Data is not stored in same order as from API response. HOT 2
- App crashed on setValue for attribute type binary data HOT 1
- APP CRASH : *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM _fastCStringContents:]: unrecognized selector sent to instance HOT 1
- reading stored data with react-native
- CFBundleShortVersionString is missing when Framework gets compiled from sources HOT 3
- Core data records lsot after app update HOT 2
- Data lost when doing light weight auto migration HOT 2
- The "sqliteOptions" is never used in MR_addAutoMigratingSqliteStoreNamed
- Warning message in Xcode11.3.1 debug area
- Reportedly missing CFBundleVersion property in info.plist HOT 1
- ICloudKit Framework integration With Magical Record
- How to get rid of β-Warc-performSelector-leaksβ warning for Xcode12.5 with SEL IMP
- Why data is fault?
- Invalid value for key 'relatedByAttribute'
- version diff crash
- Causing crash when i run my project in Xcode 13 HOT 1
- Model.mapping(map: Map(mappingType: .fromJSON, JSON: meetingJson)) not saving ID
- Documentation Related to versioning or migrating data
- Exception due to magical record library (I am using M1 mac book)
- Fetch Record using mr_findFirst gives sometimes Empty Records & SQLite file not gives valid save records. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magicalrecord.