Permalink
Browse files

Merge pull request #1 from pandamonia/master

Hopefully some useful updates from @pandamonia.
  • Loading branch information...
zwaldowski committed Nov 13, 2011
2 parents d16990b + 606705a commit 53e6f3b2000a219241fb9df3d4870926326575d9
Showing with 1,367 additions and 1,329 deletions.
  1. +8 −7 Mac App Unit Tests/Mac App Unit Tests-Prefix.pch
  2. +28 −18 Magical Record.xcodeproj/project.pbxproj
  3. +50 −41 Source/Categories/NSManagedObject+MagicalDataImport.h
  4. +210 −210 Source/Categories/NSManagedObject+MagicalDataImport.m
  5. +188 −188 Source/Categories/NSManagedObject+MagicalRecord.m
  6. +62 −62 Source/Categories/NSManagedObjectContext+MagicalRecord.m
  7. +13 −13 Source/Categories/NSManagedObjectModel+MagicalRecord.m
  8. +17 −17 Source/Categories/NSPersistentStore+MagicalRecord.m
  9. +79 −79 Source/Categories/NSPersistentStoreCoordinator+MagicalRecord.m
  10. +3 −3 Source/MRCoreDataAction.h
  11. +39 −39 Source/MRCoreDataAction.m
  12. +2 −2 Source/MagicalRecordHelpers.h
  13. +140 −134 Source/MagicalRecordHelpers.m
  14. +1 −1 Unit Tests/Fixtures/FixtureHelpers.h
  15. +17 −17 Unit Tests/Fixtures/FixtureHelpers.m
  16. +42 −42 Unit Tests/Fixtures/ImportSingleEntityRelatedToManyMappedEntitiesUsingListOfPrimaryKeysTests.m
  17. +7 −7 Unit Tests/ImportSingleEntityRelatedToManyMappedEntitiesUsingMappedPrimaryKeyTests.m
  18. +30 −30 Unit Tests/ImportSingleEntityRelatedToMappedEntityUsingDefaultsTests.m
  19. +66 −66 Unit Tests/ImportSingleEntityRelatedToMappedEntityUsingMappedPrimaryKeyTests.m
  20. +8 −8 Unit Tests/ImportSingleEntityRelatedToMappedEntityWithNestedMappedAttributesTests.m
  21. +7 −7 Unit Tests/ImportSingleEntityRelatedToMappedEntityWithSecondaryMappingsTests.m
  22. +49 −49 Unit Tests/ImportSingleEntityWithNoRelationshipsTests.m
  23. +37 −37 Unit Tests/ImportSingleRelatedEntityTests.m
  24. +6 −2 Unit Tests/MagicalDataImportTestCase.h
  25. +13 −13 Unit Tests/MagicalDataImportTestCase.m
  26. +3 −3 Unit Tests/MagicalRecordHelperTests.h
  27. +84 −75 Unit Tests/MagicalRecordHelperTests.m
  28. +1 −1 Unit Tests/NSManagedObjectContextHelperTests.h
  29. +7 −7 Unit Tests/NSManagedObjectContextHelperTests.m
  30. +1 −1 Unit Tests/NSManagedObjectHelperTests.h
  31. +47 −47 Unit Tests/NSManagedObjectHelperTests.m
  32. +1 −1 Unit Tests/NSManagedObjectModelHelperTests.h
  33. +1 −1 Unit Tests/NSManagedObjectModelHelperTests.m
  34. +1 −1 Unit Tests/NSPersisentStoreHelperTests.h
  35. +61 −62 Unit Tests/NSPersisentStoreHelperTests.m
  36. +1 −1 Unit Tests/NSPersistentStoreCoordinatorHelperTests.h
  37. +26 −26 Unit Tests/NSPersistentStoreCoordinatorHelperTests.m
  38. +11 −11 iOS App Unit Tests/iOS App Unit Tests-Prefix.pch
@@ -3,13 +3,14 @@
//
#ifdef __OBJC__
- #import <Cocoa/Cocoa.h>
- #import <GHUnit/GHUnit.h>
+ #import <Cocoa/Cocoa.h>
+ #import <GHUnit/GHUnit.h>
+ #import <OCMock/OCMock.h>
- #define HC_SHORTHAND
- #import <OCHamcrest/OCHamcrest.h>
+ #define HC_SHORTHAND
+ #import <OCHamcrest/OCHamcrest.h>
- #define MR_SHORTHAND
- #import "CoreData+MagicalRecord.h"
- #import "FixtureHelpers.h"
+ #define MR_SHORTHAND
+ #import "CoreData+MagicalRecord.h"
+ #import "FixtureHelpers.h"
#endif

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -8,57 +8,66 @@
/** Importing for Core Data.
- These utilities do their best to safely, securely, and
- efficiently import Core Data objects using NSDictionary and
- NSArray to do the bulk of the work. This allows you to simply
- import to your data model from JSON, XML, or HTTP requests
- without worrying about finding and keeping track of
- existing objects yourself.
-
- On the whole, the update methods are slower because they
- always look for existing objects for relationships. However,
- it is only recommended to import when you are sure the new
- objects (and all relationships they contain) aren't already
- in the model, unless you plan on writing yourself a grand
- old garbage collection/duplicate resolution algorithm.
-
- Magical Record will use a number of user info keys on your
- entities, their attributes, and their relationships to import.
- They are as follows:
+ These utilities do their best to safely, securely, and efficiently import Core
+ Data objects using NSDictionary and NSArray to do the bulk of the work. This
+ allows you to simply import to your data model from JSON, XML, or HTTP requests
+ without worrying about finding and keeping track of existing objects yourself.
+
+ On the whole, the update methods are slower because they always look for
+ existing objects for relationships. However, it is only recommended to import
+ when you are sure the new objects (and all relationships they contain) aren't
+ already in the model, unless you plan on writing yourself a grand old garbage
+ collection/duplicate resolution algorithm.
+
+ MagicalRecord will use a number of user info keys on your entities, their
+ attributes, and their relationships to import. They are as follows:
*Entities*
- - `className`. The value of this is used to determine what key in
- the dictionary should be used to determine the class name/entity name
- of the model the dictionary correlates to. This is especially useful
- for importing sub-entities in relationships.
- - `primaryAttribute`. The value for this key is used for comparing
- and locating model objects. If no value is provided for this key,
- Magical Record will search for a property with the name xID, where
- x is the first letter of the entity name in lowercase.
+ - `className` (`kMagicalRecordImportClassNameKey`): The value of this is used
+ to determine what key in the dictionary should be used to determine the class
+ name/entity name of the model the dictionary correlates to. This is especially
+ useful for importing sub-entities in relationships.
+ - `primaryAttribute` (`kMagicalRecordImportPrimaryAttributeKey`): The value for
+ this key is used for comparing and locating model objects. If no value is
+ provided for this key, MagicalRecord will search for a property with the name
+ `xID`, where `x` is the first letter of the entity name in lowercase.
*Attributes*
- - `mappedKey`. The value of this is used to determine what a key
- in the dictionary should be inserted into the model as. To set the
- property "lastModify" on an entity using a dictionary that has a key
+ - `mappedKey` (`kMagicalRecordImportMapKey`): The value of this is used to
+ determine what a key in the dictionary should be inserted into the model as. To
+ set the property "lastModify" on an entity using a dictionary that has a key
"lastModifiedDate", set `mappedKey` to "lastModifiedDate" on that attribute.
- - `className`. Similar to its use at the entity level, this forces the
- class of the imported object into that of the value for this key. Note
- that it is recommended to use value transformers instead.
- - `dateFormat`. For a date attribute, Magical Record can automatically
- format a string into a date object. The value of this key is used in
- the date formatter. If it is not set, "yyyy-MM-dd'T'HH:mm:ss'Z'" is
- used by default.
+ - `className` (`kMagicalRecordImportClassNameKey`): Similar to its use at the
+ entity level, this forces the class of the imported object into that of the
+ value for this key. Note that it is recommended to use value transformers
+ instead.
+ - `dateFormat` (`kMagicalRecordImportCustomDateFormat`): For a date attribute,
+ MagicalRecord can automatically format a string into a date object. The value
+ of this key is used in the date formatter. If it is not set,
+ "yyyy-MM-dd'T'HH:mm:ss'Z'" (`kMagicalRecordImportDefaultDateFormat`) is used by
+ default.
*Relationships*
- - `mappedKey`. Same as for an attribute.
- - `primaryKey`. Compare to `primaryAttribute`. This
- key is used in relationships to define what objects
- to search for when associating different model objects
- using relationships in imported dictionaries.
- */
+ - `mappedKey` (`kMagicalRecordImportMapKey`): Same as for an attribute.
+ - `primaryKey` (`kMagicalRecordImportRelationshipPrimaryKey`): Compare to
+ `primaryAttribute`. This key is used in relationships to define what objects to
+ search for when associating different model objects using relationships in
+ imported dictionaries.
+
+ **/
+
+extern NSString * const kMagicalRecordImportCustomDateFormat;
+extern NSString * const kMagicalRecordImportDefaultDateFormat;
+
+extern NSString * const kMagicalRecordImportMapKey;
+extern NSString * const kMagicalRecordImportClassNameKey;
+
+extern NSString * const kMagicalRecordImportPrimaryAttributeKey;
+extern NSString * const kMagicalRecordImportRelationshipPrimaryKey;
+
@interface NSManagedObject (MagicalDataImport)
/** Imports values into a managed object by using
Oops, something went wrong.

0 comments on commit 53e6f3b

Please sign in to comment.