Permalink
Browse files

Update threading instructions

  • Loading branch information...
1 parent ffc8a0c commit cce797d035b99f558b742dc79d276537e3bc48a0 @casademora casademora committed Apr 20, 2011
Showing with 12 additions and 7 deletions.
  1. +0 −1 CNAME
  2. +12 −6 README.md
View
1 CNAME
@@ -1 +0,0 @@
-code.magicalpanda.com
View
18 README.md
@@ -14,9 +14,9 @@ Active Record for Core Data was inspired by the ease of Ruby on Rails' Active Re
# Installation
-In your XCode Project, add all the .h and .m files into your project.
-Add the proper import states for the .h files either to your specific files using Core Data, or in your pre-compiled header file
-Start writing code! ... There is no step 3!
+- In your XCode Project, add all the .h and .m files into your project.
+- Add the proper import states for the .h files either to your specific files using Core Data, or in your pre-compiled header file
+- Start writing code! ... There is no step 3!
# Usage
@@ -30,6 +30,10 @@ Next, somewhere in your app's startup, say in the applicationDidFinishLaunching:
+ (void) setupCoreDataStackWithInMemoryStore;
+ (void) setupCoreDataStackWithStoreNamed:(NSString *)storeName;
+ (void) setupCoreDataStackWithAutoMigratingSqliteStoreNamed:(NSString *)storeName;
+
+ - or -
+
+Simply start creating, fetching and updating objects. A default stack will be created for you automatically if one does not already exist. It's magical :)
And, before your app exits, you can use the clean up method:
@@ -182,15 +186,17 @@ CoreDataBlock is typedef'd as:
All the boilerplate operations that need to be done when saving are done in these methods. To use this method from the *main thread*:
- Person *p = ...;
- [ActiveRecordHelpers performSaveDataOperationWithBlock:^(NSManagedObjectContext *localContext){
- Person *localPerson = [localContext objectWithID:p.objectID];
+ Person *person = ...;
+ [ARCoreDataAction saveDataInBackgroundWithBlock:^(NSManagedObjectContext *localContext){
+ Person *localPerson = [person inContext:localContext];
localPerson.firstName = @"Chuck";
localPerson.lastName = @"Smith";
}];
In this method, the CoreDataBlock provides you with the proper context in which to perform your operations, you don't need to worry about setting up the context so that it tells the Default Context that it's done, and should update because changes were performed on another thread.
+
+All ARCoreDataActions have a dedicated GCD queue on which they operate. This means that throughout your app, you only really have 2 threads performing Core Data actions at any one time: one on the main thread, and another on this dedicated GCD queue.
# Extra Bits
This Code is released under the MIT License by [Magical Panda Software, LLC.](http://www.magicalpanda.com)

0 comments on commit cce797d

Please sign in to comment.