├── DCTCoreDataTests
├── en.lproj
│ └── InfoPlist.strings
├── DCTCoreDataTests.h
├── DCTCoreDataTests.m
└── DCTCoreDataTests-Info.plist
├── DCTCoreData.xcodeproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── project.pbxproj
├── DCTCoreData
├── DCTCoreData.h
├── Automated Setup
│ ├── NSDictionary+DCTKeyForObject.h
│ ├── NSEntityDescription+DCTObjectCheck.h
│ ├── NSAttributeDescription+DCTObjectCheck.h
│ ├── NSEntityDescription+DCTObjectCheck.m
│ ├── NSDictionary+DCTKeyForObject.m
│ ├── NSAttributeDescription+DCTObjectCheck.m
│ ├── NSManagedObject+DCTAutomatedSync.h
│ ├── NSManagedObject+DCTAutomatedSetup.h
│ ├── NSManagedObject+DCTAutomatedSync.m
│ └── NSManagedObject+DCTAutomatedSetup.m
├── NSManagedObject+DCTExtras.h
├── NSFetchedResultsController+DCTExtras.h
├── NSArray+DCTSortDescriptors.h
├── NSManagedObject+DCTRelatedObjects.h
├── NSManagedObject+DCTExtras.m
├── NSFetchedResultsController+DCTExtras.m
├── NSArray+DCTSortDescriptors.m
├── NSManagedObjectContext+DCTExtras.h
├── NSManagedObject+DCTOrdering.h
├── NSManagedObject+DCTRelatedObjects.m
├── NSManagedObjectContext+DCTDataFetching.h
├── NSFetchRequest+DCTExtras.h
├── NSManagedObjectContext+DCTExtras.m
├── NSPredicate+DCTExtras.h
├── Asynchronous
│ ├── NSManagedObjectContext+DCTAsynchronousDataFetching.h
│ ├── NSManagedObjectContext+DCTAsynchronousTasks.h
│ ├── NSManagedObjectContext+DCTAsynchronousDataFetching.m
│ └── NSManagedObjectContext+DCTAsynchronousTasks.m
├── NSPredicate+DCTExtras.m
├── NSFetchRequest+DCTExtras.m
├── NSManagedObjectContext+DCTDataFetching.m
└── NSManagedObject+DCTOrdering.m
└── Readme.textile
/DCTCoreDataTests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/DCTCoreData.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/DCTCoreDataTests/DCTCoreDataTests.h:
--------------------------------------------------------------------------------
1 | //
2 | // DCTCoreDataTests.h
3 | // DCTCoreDataTests
4 | //
5 | // Created by Daniel Tull on 14.06.2012.
6 | // Copyright (c) 2012 Daniel Tull. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface DCTCoreDataTests : SenTestCase
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/DCTCoreDataTests/DCTCoreDataTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // DCTCoreDataTests.m
3 | // DCTCoreDataTests
4 | //
5 | // Created by Daniel Tull on 14.06.2012.
6 | // Copyright (c) 2012 Daniel Tull. All rights reserved.
7 | //
8 |
9 | #import "DCTCoreDataTests.h"
10 |
11 | @implementation DCTCoreDataTests
12 |
13 | - (void)setUp
14 | {
15 | [super setUp];
16 |
17 | // Set-up code here.
18 | }
19 |
20 | - (void)tearDown
21 | {
22 | // Tear-down code here.
23 |
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample
28 | {
29 | STFail(@"Unit tests are not implemented yet in DCTCoreDataTests");
30 | }
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/DCTCoreDataTests/DCTCoreDataTests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | uk.co.danieltull.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/DCTCoreData/DCTCoreData.h:
--------------------------------------------------------------------------------
1 | //
2 | // DCTCoreData.h
3 | // DCTFoursquare
4 | //
5 | // Created by Daniel Tull on 21.01.2012.
6 | // Copyright (c) 2012 Daniel Tull Limited. All rights reserved.
7 | //
8 |
9 | #ifndef dctcoredata
10 | #define dctcoredata_1_0 10000
11 | #define dctcoredata_1_0_1 10001
12 | #define dctcoredata_1_0_2 10002
13 | #define dctcoredata_1_1 10100
14 | #define dctcoredata_1_1_1 10101
15 | #define dctcoredata_1_2 10200
16 | #define dctcoredata_1_3 10300
17 | #define dctcoredata_1_3_1 10301
18 | #define dctcoredata_2_0 20000
19 | #define dctcoredata_2_0_1 20001
20 | #define dctcoredata_2_1 20100
21 | #define dctcoredata_2_2 20200
22 | #define dctcoredata dctcoredata_2_2
23 | #endif
24 |
25 | #import
26 | #import
27 | #import
28 | #import
29 | #import
30 | #import
31 | #import
32 | #import
33 | #import
34 |
35 | // Automated Setup
36 | #import "NSManagedObject+DCTAutomatedSetup.h"
37 | #import "NSManagedObject+DCTAutomatedSync.h"
38 |
39 | // Asynchronous
40 | #import "NSManagedObjectContext+DCTAsynchronousDataFetching.h"
41 | #import "NSManagedObjectContext+DCTAsynchronousTasks.h"
--------------------------------------------------------------------------------
/DCTCoreData/Automated Setup/NSDictionary+DCTKeyForObject.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSDictionary+DCTKeyForObject.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 12.08.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 |
39 | @interface NSDictionary (DCTKeyForObject)
40 | - (id)dct_keyForObject:(id)object;
41 | @end
42 |
--------------------------------------------------------------------------------
/DCTCoreData/Automated Setup/NSEntityDescription+DCTObjectCheck.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSEntityDescription+DCTObjectCheck.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 11.08.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 |
39 | @interface NSEntityDescription (DCTObjectCheck)
40 |
41 | - (BOOL)dct_isObjectValid:(id)object;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/DCTCoreData/NSManagedObject+DCTExtras.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObject+DCTExtras.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 29.09.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 |
39 |
40 | @interface NSManagedObject (DCTExtras)
41 |
42 | - (NSAttributeDescription *)dct_attributeDescriptionForKey:(NSString *)key;
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/DCTCoreData/NSFetchedResultsController+DCTExtras.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSFetchedResultsController+DCTExtras.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 18.02.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 | #import
39 |
40 | @interface NSFetchedResultsController (DCTExtras)
41 |
42 | - (BOOL)dct_performFetch;
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/DCTCoreData/NSArray+DCTSortDescriptors.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSArray+DCTSortDescriptors.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 18.02.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 | #import
39 |
40 | @interface NSArray (DCTSortDescriptors)
41 | + (NSArray *)dct_sortDescriptorsArrayWithKey:(NSString *)key ascending:(BOOL)ascending;
42 | @end
43 |
--------------------------------------------------------------------------------
/DCTCoreData/Automated Setup/NSAttributeDescription+DCTObjectCheck.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSAttributeDescription+DCTObjectCheck.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 11.08.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 |
39 | @interface NSAttributeDescription (DCTObjectCheck)
40 |
41 | - (BOOL)dct_isObjectValid:(id)object;
42 | - (BOOL)dct_isClassValid:(Class)aClass;
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/DCTCoreData/Automated Setup/NSEntityDescription+DCTObjectCheck.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSEntityDescription+DCTObjectCheck.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 11.08.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSEntityDescription+DCTObjectCheck.h"
38 |
39 | @implementation NSEntityDescription (DCTObjectCheck)
40 |
41 | - (BOOL)dct_isObjectValid:(id)object {
42 | return [[self managedObjectClassName] isEqualToString:NSStringFromClass([object class])];
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/DCTCoreData/Automated Setup/NSDictionary+DCTKeyForObject.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSDictionary+DCTKeyForObject.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 12.08.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSDictionary+DCTKeyForObject.h"
38 |
39 |
40 | @implementation NSDictionary (DCTKeyForObject)
41 |
42 | - (id)dct_keyForObject:(id)object {
43 |
44 | for (id key in self) {
45 | id o = [self objectForKey:key];
46 |
47 | if (o == object) return key;
48 | }
49 |
50 | return nil;
51 | }
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/DCTCoreData/NSManagedObject+DCTRelatedObjects.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObject+DCTRelatedObjects.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 14.08.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 |
39 | @interface NSManagedObject (DCTRelatedObjects)
40 |
41 | - (void)dct_addRelatedObject:(id)value forKey:(NSString *)key;
42 | - (void)dct_removeRelatedObject:(id)value forKey:(NSString *)key;
43 | - (void)dct_replaceRelatedObject:(id)oldObject withRelatedObject:(id)newObject forKey:(NSString *)key;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/DCTCoreData/NSManagedObject+DCTExtras.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObject+DCTExtras.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 29.09.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSManagedObject+DCTExtras.h"
38 |
39 | @implementation NSManagedObject (DCTExtras)
40 |
41 | - (NSAttributeDescription *)dct_attributeDescriptionForKey:(NSString *)key {
42 |
43 | NSEntityDescription *entity = [self entity];
44 | NSDictionary *attributesByName = [entity attributesByName];
45 |
46 | return [attributesByName objectForKey:key];
47 | }
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/DCTCoreData/NSFetchedResultsController+DCTExtras.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSFetchedResultsController+DCTExtras.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 18.02.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSFetchedResultsController+DCTExtras.h"
38 |
39 |
40 | @implementation NSFetchedResultsController (DCTExtras)
41 |
42 | - (BOOL)dct_performFetch {
43 |
44 | NSError *error = nil;
45 |
46 | if (![self performFetch:&error]) {
47 | NSLog(@"%@:%@ %@", self, NSStringFromSelector(_cmd), error);
48 | return NO;
49 | }
50 |
51 | return YES;
52 | }
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/DCTCoreData/NSArray+DCTSortDescriptors.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSArray+DCTSortDescriptors.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 18.02.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSArray+DCTSortDescriptors.h"
38 |
39 |
40 | @implementation NSArray (DCTSortDescriptors)
41 |
42 | + (NSArray *)dct_sortDescriptorsArrayWithKey:(NSString *)key ascending:(BOOL)ascending {
43 | NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:key ascending:ascending];
44 | NSArray *descriptors = [NSArray arrayWithObject:sortDescriptor];
45 | return descriptors;
46 | }
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/DCTCoreData/Automated Setup/NSAttributeDescription+DCTObjectCheck.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSAttributeDescription+DCTObjectCheck.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 11.08.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSAttributeDescription+DCTObjectCheck.h"
38 |
39 | @implementation NSAttributeDescription (DCTObjectCheck)
40 |
41 | - (BOOL)dct_isObjectValid:(id)object {
42 |
43 | Class attributeClass = NSClassFromString([self attributeValueClassName]);
44 |
45 | return ([object isKindOfClass:attributeClass] || [self attributeType] == NSTransformableAttributeType);
46 | }
47 |
48 | - (BOOL)dct_isClassValid:(Class)aClass {
49 |
50 | Class attributeClass = NSClassFromString([self attributeValueClassName]);
51 |
52 | return (aClass == attributeClass);
53 | }
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/DCTCoreData/NSManagedObjectContext+DCTExtras.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObjectContext+DCTExtras.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 4.11.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 |
39 | @interface NSManagedObjectContext (DCTExtras)
40 |
41 | - (NSManagedObjectModel *)dct_managedObjectModel;
42 |
43 | - (void)dct_performAndWaitWithObjectID:(NSManagedObjectID *)objectID block:(void (^)(NSManagedObject *))block;
44 | - (void)dct_performWithObjectID:(NSManagedObjectID *)objectID block:(void (^)(NSManagedObject *))block;
45 |
46 | - (void)dct_performWithObjectIDs:(NSArray *)objectIDs block:(void (^)(NSArray *objects))block;
47 | - (void)dct_performAndWaitWithObjectIDs:(NSArray *)objectIDs block:(void (^)(NSArray *objects))block;
48 |
49 | - (id)dct_safeObjectWithID:(NSManagedObjectID *)objectID;
50 |
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/DCTCoreData/Automated Setup/NSManagedObject+DCTAutomatedSync.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObject+DCTAutomatedSync.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 20.09.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 | #import "NSManagedObject+DCTAutomatedSetup.h"
39 |
40 | typedef enum {
41 | DCTManagedObjectAutomatedSyncStatusNil = 0,
42 | DCTManagedObjectAutomatedSyncStatusUp,
43 | DCTManagedObjectAutomatedSyncStatusNone,
44 | DCTManagedObjectAutomatedSyncStatusDown
45 | } DCTManagedObjectAutomatedSyncStatus;
46 |
47 | @interface NSManagedObject (DCTAutomatedSync)
48 |
49 | - (void)dct_syncWithDictionary:(NSDictionary *)dictionary;
50 |
51 | @end
52 |
53 |
54 | @protocol DCTManagedObjectAutomatedSync
55 |
56 | @optional
57 | - (DCTManagedObjectAutomatedSyncStatus)dct_syncStatusForDictionary:(NSDictionary *)dictionary;
58 | - (NSString *)dct_lastUpdatedDateKey;
59 | - (void)dct_synchroniseToSource;
60 |
61 | @end
62 |
--------------------------------------------------------------------------------
/DCTCoreData/NSManagedObject+DCTOrdering.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObject+DCTOrdering.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 14.08.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 |
39 | @protocol DCTOrderedObject;
40 |
41 | @interface NSManagedObject (DCTOrdering)
42 |
43 | - (void)dct_addOrderedObject:(NSManagedObject *)object forKey:(NSString *)key;
44 | - (void)dct_addOrderedObject:(NSManagedObject *)object forKey:(NSString *)key lastObject:(NSManagedObject *)last;
45 |
46 | - (void)dct_insertOrderedObject:(NSManagedObject *)object atIndex:(NSUInteger)index forKey:(NSString *)key;
47 | - (void)dct_removeOrderedObjectAtIndex:(NSUInteger)index forKey:(NSString *)key;
48 |
49 | - (NSManagedObject *)dct_orderedObjectAtIndex:(NSUInteger)index forKey:(NSString *)key;
50 | - (NSManagedObject *)dct_lastOrderedObjectForKey:(NSString *)key;
51 | - (NSManagedObject *)dct_firstOrderedObjectForKey:(NSString *)key;
52 |
53 | - (NSArray *)dct_orderedObjectsForKey:(NSString *)key;
54 |
55 | @end
56 |
57 |
58 | @protocol DCTOrderedObject
59 |
60 | @required
61 | @property (nonatomic, retain) NSNumber *dctOrderedObjectIndex;
62 |
63 | @optional
64 | @property (nonatomic, retain) NSManagedObject *dctPreviousOrderedObject;
65 | @property (nonatomic, retain) NSManagedObject *dctNextOrderedObject;
66 |
67 | @end
68 |
--------------------------------------------------------------------------------
/DCTCoreData/NSManagedObject+DCTRelatedObjects.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObject+DCTRelatedObjects.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 14.08.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSManagedObject+DCTRelatedObjects.h"
38 |
39 |
40 | @implementation NSManagedObject (DCTRelatedObjects)
41 |
42 | - (void)dct_addRelatedObject:(id)object forKey:(NSString *)key {
43 | NSSet *changedObjects = [[NSSet alloc] initWithObjects:&object count:1];
44 |
45 | [self willChangeValueForKey:key withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
46 |
47 | [[self primitiveValueForKey:key] addObject:object];
48 |
49 | [self didChangeValueForKey:key withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
50 |
51 | }
52 |
53 | - (void)dct_removeRelatedObject:(id)object forKey:(NSString *)key {
54 | NSSet *changedObjects = [[NSSet alloc] initWithObjects:&object count:1];
55 |
56 | [self willChangeValueForKey:key withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
57 |
58 | [[self primitiveValueForKey:key] removeObject:object];
59 |
60 | [self didChangeValueForKey:key withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
61 |
62 | }
63 |
64 | - (void)dct_replaceRelatedObject:(id)oldObject withRelatedObject:(id)newObject forKey:(NSString *)key {
65 | NSSet *changedObjects = [[NSSet alloc] initWithObjects:&newObject count:1];
66 |
67 | [self willChangeValueForKey:key withSetMutation:NSKeyValueSetSetMutation usingObjects:changedObjects];
68 |
69 | [[self primitiveValueForKey:key] removeObject:oldObject];
70 | [[self primitiveValueForKey:key] addObject:newObject];
71 |
72 | [self didChangeValueForKey:key withSetMutation:NSKeyValueSetSetMutation usingObjects:changedObjects];
73 |
74 | }
75 |
76 | @end
77 |
--------------------------------------------------------------------------------
/DCTCoreData/NSManagedObjectContext+DCTDataFetching.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObjectContext+DCTDataFetching.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 16.09.2009.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 |
39 | @interface NSManagedObjectContext (DCTDataFetching)
40 |
41 | #pragma mark -
42 | #pragma mark Fetching Multiple Objects
43 |
44 | /* If the fetch fails, the error will be logged
45 | */
46 |
47 | - (NSArray *)dct_fetchObjectsForEntityName:(NSString *)entityName;
48 |
49 | - (NSArray *)dct_fetchObjectsForEntityName:(NSString *)entityName
50 | predicate:(NSPredicate *)predicate;
51 |
52 | - (NSArray *)dct_fetchObjectsForEntityName:(NSString *)entityName
53 | predicate:(NSPredicate *)predicate
54 | sortDescriptors:(NSArray *)sortDescriptors;
55 |
56 | - (NSArray *)dct_fetchObjectsForEntityName:(NSString *)entityName
57 | sortDescriptors:(NSArray *)sortDescriptors;
58 |
59 | - (NSArray *)dct_fetchObjectsForEntityName:(NSString *)entityName
60 | predicate:(NSPredicate *)predicate
61 | sortDescriptors:(NSArray *)sortDescriptors
62 | batchSize:(NSUInteger)batchSize;
63 |
64 | #pragma mark -
65 | #pragma mark Fetching Single Objects
66 |
67 | - (id)dct_fetchAnyObjectForEntityName:(NSString *)entityName;
68 |
69 | - (id)dct_fetchAnyObjectForEntityName:(NSString *)entityName
70 | predicate:(NSPredicate *)predicate;
71 |
72 | - (id)dct_fetchFirstObjectForEntityName:(NSString *)entityName
73 | sortDescriptors:(NSArray *)sortDescriptors;
74 |
75 | - (id)dct_fetchFirstObjectForEntityName:(NSString *)entityName
76 | predicate:(NSPredicate *)predicate
77 | sortDescriptors:(NSArray *)sortDescriptors;
78 |
79 | #pragma mark -
80 | #pragma mark Inserting New Objects
81 |
82 | - (id)dct_insertNewObjectForEntityName:(NSString *)entityName;
83 | @end
84 |
--------------------------------------------------------------------------------
/DCTCoreData/NSFetchRequest+DCTExtras.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSFetchRequest+DCTExtras.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 18.02.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 |
39 | extern NSUInteger const DCTFetchBatchSizeNil;
40 |
41 | @interface NSFetchRequest (DCTExtras)
42 |
43 | + (id)dct_fetchRequestWithEntity:(NSEntityDescription *)entity;
44 |
45 | + (id)dct_fetchRequestWithEntity:(NSEntityDescription *)entity
46 | predicate:(NSPredicate *)predicate;
47 |
48 | + (id)dct_fetchRequestWithEntity:(NSEntityDescription *)entity
49 | sortDescriptors:(NSArray *)sortDescriptors;
50 |
51 | + (id)dct_fetchRequestWithEntity:(NSEntityDescription *)entity
52 | predicate:(NSPredicate *)predicate
53 | sortDescriptors:(NSArray *)sortDescriptors;
54 |
55 | + (id)dct_fetchRequestWithEntity:(NSEntityDescription *)entity
56 | predicate:(NSPredicate *)predicate
57 | sortDescriptors:(NSArray *)sortDescriptors
58 | batchSize:(NSUInteger)batchSize;
59 |
60 | - (id)dct_initWithEntity:(NSEntityDescription *)entity __attribute__((ns_consumes_self))__attribute__((ns_returns_retained));
61 |
62 | - (id)dct_initWithEntity:(NSEntityDescription *)entity
63 | predicate:(NSPredicate *)predicate __attribute__((ns_consumes_self))__attribute__((ns_returns_retained));
64 |
65 | - (id)dct_initWithEntity:(NSEntityDescription *)entity
66 | sortDescriptors:(NSArray *)sortDescriptors __attribute__((ns_consumes_self))__attribute__((ns_returns_retained));
67 |
68 | - (id)dct_initWithEntity:(NSEntityDescription *)entity
69 | predicate:(NSPredicate *)predicate
70 | sortDescriptors:(NSArray *)sortDescriptors __attribute__((ns_consumes_self))__attribute__((ns_returns_retained));
71 |
72 | - (id)dct_initWithEntity:(NSEntityDescription *)entity
73 | predicate:(NSPredicate *)predicate
74 | sortDescriptors:(NSArray *)sortDescriptors
75 | batchSize:(NSUInteger)batchSize __attribute__((ns_consumes_self))__attribute__((ns_returns_retained));
76 |
77 | @end
78 |
--------------------------------------------------------------------------------
/DCTCoreData/NSManagedObjectContext+DCTExtras.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObjectContext+DCTExtras.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 4.11.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSManagedObjectContext+DCTExtras.h"
38 |
39 | @implementation NSManagedObjectContext (DCTExtras)
40 |
41 | - (id)dct_safeObjectWithID:(NSManagedObjectID *)objectID {
42 |
43 | if (!objectID) return nil;
44 |
45 | return [self objectWithID:objectID];
46 | }
47 |
48 |
49 | - (void)dct_performAndWaitWithObjectID:(NSManagedObjectID *)objectID block:(void (^)(NSManagedObject *object))block {
50 |
51 | [self performBlockAndWait:^{
52 | block([self objectWithID:objectID]);
53 | }];
54 | }
55 |
56 | - (void)dct_performWithObjectID:(NSManagedObjectID *)objectID block:(void (^)(NSManagedObject *object))block {
57 |
58 | NSAssert(objectID != nil, @"objectID should not be nil");
59 | NSAssert(block != nil, @"block should not be nil");
60 |
61 | [self performBlock:^{
62 | block([self objectWithID:objectID]);
63 | }];
64 | }
65 |
66 | - (void)dct_performWithObjectIDs:(NSArray *)objectIDs block:(void (^)(NSArray *objects))block {
67 |
68 | NSAssert(objectIDs != nil, @"objectIDs should not be nil");
69 | NSAssert(block != nil, @"block should not be nil");
70 |
71 | [self performBlock:^{
72 |
73 | NSMutableArray *objects = [[NSMutableArray alloc] initWithCapacity:[objectIDs count]];
74 |
75 | [objectIDs enumerateObjectsUsingBlock:^(NSManagedObjectID *objectID, NSUInteger idx, BOOL *stop) {
76 | [objects addObject:[self objectWithID:objectID]];
77 | }];
78 |
79 | block([objects copy]);
80 | }];
81 | }
82 |
83 | - (void)dct_performAndWaitWithObjectIDs:(NSArray *)objectIDs block:(void (^)(NSArray *objects))block {
84 | [self performBlockAndWait:^{
85 |
86 | NSMutableArray *objects = [[NSMutableArray alloc] initWithCapacity:[objectIDs count]];
87 |
88 | [objectIDs enumerateObjectsUsingBlock:^(NSManagedObjectID *objectID, NSUInteger idx, BOOL *stop) {
89 | [objects addObject:[self objectWithID:objectID]];
90 | }];
91 |
92 | block([objects copy]);
93 | }];
94 | }
95 |
96 | - (NSManagedObjectModel *)dct_managedObjectModel {
97 | return [[self persistentStoreCoordinator] managedObjectModel];
98 | }
99 |
100 | @end
101 |
--------------------------------------------------------------------------------
/DCTCoreData/NSPredicate+DCTExtras.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSPredicate+DCTExtras.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 16.06.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 |
39 | @interface NSPredicate (DCTExtras)
40 |
41 | /** Returns a predictate where the given name or keypath equals the given object.
42 |
43 | @param nameOrKeyPath This can be the property name, a keypath as an NSString or an NSArray
44 | @param object The object to compare
45 | */
46 | + (NSPredicate *)dct_predicateWhereProperty:(id)nameOrKeyPath equals:(id)object;
47 |
48 | /** Returns a predictate where the given name or keypath is greater than the given object.
49 |
50 | @param nameOrKeyPath This can be the property name, a keypath as an NSString or an NSArray
51 | @param object The object to compare
52 | */
53 | + (NSPredicate *)dct_predicateWhereProperty:(id)nameOrKeyPath isGreaterThan:(id)object;
54 |
55 | /** Returns a predictate where the given name or keypath is less than the given object.
56 |
57 | @param nameOrKeyPath This can be the property name, a keypath as an NSString or an NSArray
58 | @param object The object to compare
59 | */
60 | + (NSPredicate *)dct_predicateWhereProperty:(id)nameOrKeyPath isLessThan:(id)object;
61 |
62 | /** Returns a predictate where the given name or keypath does not equal the given object.
63 |
64 | @param nameOrKeyPath This can be the property name, a keypath as an NSString or an NSArray
65 | @param object The object to compare
66 | */
67 | + (NSPredicate *)dct_predicateWhereProperty:(id)nameOrKeyPath doesNotEqual:(id)object;
68 |
69 | /** Returns a predictate where the given name or keypath is tested for nil.
70 |
71 | @param nameOrKeyPath This can be the property name, a keypath as an NSString or an NSArray
72 | */
73 | + (NSPredicate *)dct_predicateWherePropertyIsNil:(NSString *)name;
74 |
75 | /** Returns a predictate where the given name or keypath is tested for not nil.
76 |
77 | @param nameOrKeyPath This can be the property name, a keypath as an NSString or an NSArray
78 | */
79 | + (NSPredicate *)dct_predicateWherePropertyIsNotNil:(NSString *)name;
80 |
81 | /** Returns a predictate where the given name or keypath is tested for not nil and not empty.
82 |
83 | @param nameOrKeyPath This can be the property name, a keypath as an NSString or an NSArray
84 | */
85 | + (NSPredicate *)dct_predicateWhereStringPropertyIsNotNilAndNotEmpty:(NSString *)name;
86 |
87 | + (NSPredicate *)dct_predicateWhereProperty:(NSString *)name contains:(id)object;
88 |
89 | @end
90 |
--------------------------------------------------------------------------------
/DCTCoreData/Asynchronous/NSManagedObjectContext+DCTAsynchronousDataFetching.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObjectContext+DCTAsynchronousDataFetching.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 4.12.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 | #import "NSManagedObjectContext+DCTAsynchronousTasks.h"
39 |
40 | @interface NSManagedObjectContext (DCTAsynchronousDataFetching)
41 |
42 | #pragma mark -
43 | #pragma mark Fetching Multiple Objects
44 |
45 | - (void)dct_asynchronousObjectsForEntityName:(NSString *)entityName
46 | callbackBlock:(DCTFetchRequestCallbackBlock)callbackBlock;
47 |
48 | - (void)dct_asynchronousObjectsForEntityName:(NSString *)entityName
49 | predicate:(NSPredicate *)predicate
50 | callbackBlock:(DCTFetchRequestCallbackBlock)callbackBlock;
51 |
52 | - (void)dct_asynchronousObjectsForEntityName:(NSString *)entityName
53 | predicate:(NSPredicate *)predicate
54 | sortDescriptors:(NSArray *)sortDescriptors
55 | callbackBlock:(DCTFetchRequestCallbackBlock)callbackBlock;
56 |
57 | - (void)dct_asynchronousObjectsForEntityName:(NSString *)entityName
58 | sortDescriptors:(NSArray *)sortDescriptors
59 | callbackBlock:(DCTFetchRequestCallbackBlock)callbackBlock;
60 |
61 | - (void)dct_asynchronousObjectsForEntityName:(NSString *)entityName
62 | predicate:(NSPredicate *)predicate
63 | sortDescriptors:(NSArray *)sortDescriptors
64 | batchSize:(NSUInteger)batchSize
65 | callbackBlock:(DCTFetchRequestCallbackBlock)callbackBlock;
66 |
67 | #pragma mark -
68 | #pragma mark Fetching Single Objects
69 |
70 | - (void)dct_asynchronousObjectForEntityName:(NSString *)entityName
71 | callbackBlock:(DCTFetchRequestObjectCallbackBlock)callbackBlock;
72 |
73 | - (void)dct_asynchronousObjectForEntityName:(NSString *)entityName
74 | predicate:(NSPredicate *)predicate
75 | callbackBlock:(DCTFetchRequestObjectCallbackBlock)callbackBlock;
76 |
77 | - (void)dct_asynchronousObjectForEntityName:(NSString *)entityName
78 | predicate:(NSPredicate *)predicate
79 | sortDescriptors:(NSArray *)sortDescriptors
80 | callbackBlock:(DCTFetchRequestObjectCallbackBlock)callbackBlock;
81 |
82 | - (void)dct_asynchronousObjectForEntityName:(NSString *)entityName
83 | sortDescriptors:(NSArray *)sortDescriptors
84 | callbackBlock:(DCTFetchRequestObjectCallbackBlock)callbackBlock;
85 |
86 | - (void)dct_asynchronousObjectForEntityName:(NSString *)entityName
87 | predicate:(NSPredicate *)predicate
88 | sortDescriptors:(NSArray *)sortDescriptors
89 | batchSize:(NSUInteger)batchSize
90 | callbackBlock:(DCTFetchRequestObjectCallbackBlock)callbackBlock;
91 |
92 | @end
93 |
--------------------------------------------------------------------------------
/DCTCoreData/NSPredicate+DCTExtras.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSPredicate+DCTExtras.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 16.06.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSPredicate+DCTExtras.h"
38 |
39 | @interface NSPredicate (DCTExtrasInternal)
40 | + (NSString *)dctExtrasInternal_keyPathFromObject:(id)object;
41 | @end
42 |
43 | @implementation NSPredicate (DCTExtras)
44 |
45 | + (NSPredicate *)dct_predicateWhereProperty:(id)nameOrKeyPath equals:(id)object {
46 | nameOrKeyPath = [self dctExtrasInternal_keyPathFromObject:nameOrKeyPath];
47 | return [NSPredicate predicateWithFormat:@"%K == %@", nameOrKeyPath, object];
48 | }
49 |
50 | + (NSPredicate *)dct_predicateWhereProperty:(id)nameOrKeyPath isGreaterThan:(id)object {
51 | nameOrKeyPath = [self dctExtrasInternal_keyPathFromObject:nameOrKeyPath];
52 | return [NSPredicate predicateWithFormat:@"%K > %@", nameOrKeyPath, object];
53 |
54 | }
55 |
56 | + (NSPredicate *)dct_predicateWhereProperty:(id)nameOrKeyPath isLessThan:(id)object {
57 | nameOrKeyPath = [self dctExtrasInternal_keyPathFromObject:nameOrKeyPath];
58 | return [NSPredicate predicateWithFormat:@"%K < %@", nameOrKeyPath, object];
59 | }
60 |
61 | + (NSPredicate *)dct_predicateWhereProperty:(id)nameOrKeyPath doesNotEqual:(id)object {
62 | nameOrKeyPath = [self dctExtrasInternal_keyPathFromObject:nameOrKeyPath];
63 | return [NSPredicate predicateWithFormat:@"%K != %@", nameOrKeyPath, object];
64 | }
65 |
66 | + (NSPredicate *)dct_predicateWherePropertyIsNil:(id)nameOrKeyPath {
67 | nameOrKeyPath = [self dctExtrasInternal_keyPathFromObject:nameOrKeyPath];
68 | return [NSPredicate predicateWithFormat:@"%K == nil", nameOrKeyPath];
69 | }
70 |
71 | + (NSPredicate *)dct_predicateWherePropertyIsNotNil:(id)nameOrKeyPath {
72 | nameOrKeyPath = [self dctExtrasInternal_keyPathFromObject:nameOrKeyPath];
73 | return [NSPredicate predicateWithFormat:@"%K != nil", nameOrKeyPath];
74 | }
75 |
76 | + (NSPredicate *)dct_predicateWhereStringPropertyIsNotNilAndNotEmpty:(id)nameOrKeyPath {
77 | nameOrKeyPath = [self dctExtrasInternal_keyPathFromObject:nameOrKeyPath];
78 | return [NSPredicate predicateWithFormat:@"%K != nil && %K != ''", nameOrKeyPath, nameOrKeyPath];
79 | }
80 |
81 | + (NSPredicate *)dct_predicateWhereProperty:(NSString *)name contains:(id)object {
82 | return [NSPredicate predicateWithFormat:@"%K CONTAINS %@", name, object];
83 | }
84 |
85 | @end
86 |
87 | @implementation NSPredicate (DCTExtrasInternal)
88 |
89 | + (NSString *)dctExtrasInternal_keyPathFromObject:(id)object {
90 |
91 | if ([object isKindOfClass:[NSString class]])
92 | return object;
93 |
94 | if ([object isKindOfClass:[NSArray class]])
95 | return [object componentsJoinedByString:@"."];
96 |
97 | [NSException raise:@"Invalid parameter" format:@"%@ should be of class NSString or NSArray", object];
98 | return nil;
99 | }
100 |
101 | @end
102 |
--------------------------------------------------------------------------------
/DCTCoreData/NSFetchRequest+DCTExtras.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSFetchRequest+DCTExtras.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 18.02.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSFetchRequest+DCTExtras.h"
38 |
39 | NSUInteger const DCTFetchBatchSizeNil = 0;
40 |
41 | @implementation NSFetchRequest (DCTExtras)
42 |
43 | + (id)dct_fetchRequestWithEntity:(NSEntityDescription *)entity {
44 | return [[self alloc] dct_initWithEntity:entity];
45 | }
46 |
47 | + (id)dct_fetchRequestWithEntity:(NSEntityDescription *)entity
48 | predicate:(NSPredicate *)predicate {
49 |
50 | return [[self alloc] dct_initWithEntity:entity
51 | predicate:predicate];
52 | }
53 |
54 | + (id)dct_fetchRequestWithEntity:(NSEntityDescription *)entity
55 | sortDescriptors:(NSArray *)sortDescriptors {
56 |
57 | return [[self alloc] dct_initWithEntity:entity
58 | sortDescriptors:sortDescriptors];
59 | }
60 |
61 | + (id)dct_fetchRequestWithEntity:(NSEntityDescription *)entity
62 | predicate:(NSPredicate *)predicate
63 | sortDescriptors:(NSArray *)sortDescriptors {
64 |
65 | return [[self alloc] dct_initWithEntity:entity
66 | predicate:predicate
67 | sortDescriptors:sortDescriptors];
68 | }
69 |
70 | + (id)dct_fetchRequestWithEntity:(NSEntityDescription *)entity
71 | predicate:(NSPredicate *)predicate
72 | sortDescriptors:(NSArray *)sortDescriptors
73 | batchSize:(NSUInteger)batchSize {
74 |
75 | return [[self alloc] dct_initWithEntity:entity
76 | predicate:predicate
77 | sortDescriptors:sortDescriptors
78 | batchSize:batchSize];
79 | }
80 |
81 | - (id)dct_initWithEntity:(NSEntityDescription *)entity {
82 |
83 | return [self dct_initWithEntity:entity
84 | predicate:nil
85 | sortDescriptors:nil
86 | batchSize:DCTFetchBatchSizeNil];
87 | }
88 |
89 | - (id)dct_initWithEntity:(NSEntityDescription *)entity
90 | predicate:(NSPredicate *)predicate {
91 |
92 | return [self dct_initWithEntity:entity
93 | predicate:predicate
94 | sortDescriptors:nil
95 | batchSize:DCTFetchBatchSizeNil];
96 | }
97 |
98 | - (id)dct_initWithEntity:(NSEntityDescription *)entity
99 | sortDescriptors:(NSArray *)sortDescriptors {
100 |
101 | return [self dct_initWithEntity:entity
102 | predicate:nil
103 | sortDescriptors:sortDescriptors
104 | batchSize:DCTFetchBatchSizeNil];
105 | }
106 |
107 | - (id)dct_initWithEntity:(NSEntityDescription *)entity
108 | predicate:(NSPredicate *)predicate
109 | sortDescriptors:(NSArray *)sortDescriptors {
110 |
111 | return [self dct_initWithEntity:entity
112 | predicate:predicate
113 | sortDescriptors:sortDescriptors
114 | batchSize:DCTFetchBatchSizeNil];
115 | }
116 |
117 | - (id)dct_initWithEntity:(NSEntityDescription *)entity
118 | predicate:(NSPredicate *)predicate
119 | sortDescriptors:(NSArray *)sortDescriptors
120 | batchSize:(NSUInteger)batchSize {
121 |
122 | NSFetchRequest *fr = [[NSFetchRequest alloc] init];
123 |
124 | [fr setEntity:entity];
125 |
126 | if (predicate) [fr setPredicate:predicate];
127 |
128 | if (sortDescriptors) [fr setSortDescriptors:sortDescriptors];
129 |
130 | if (batchSize != DCTFetchBatchSizeNil) [fr setFetchBatchSize:batchSize];
131 |
132 | return fr;
133 | }
134 |
135 | @end
136 |
--------------------------------------------------------------------------------
/DCTCoreData/Asynchronous/NSManagedObjectContext+DCTAsynchronousTasks.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObjectContext+DCTAsynchronousTasks.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 4.12.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 | #import
39 |
40 | typedef void (^DCTManagedObjectContextBlock) (NSManagedObjectContext *managedObjectContext);
41 |
42 | typedef void (^DCTManagedObjectContextObjectBlock) (NSManagedObjectContext *managedObjectContext, id managedObject);
43 | typedef void (^DCTManagedObjectContextObjectsBlock) (NSManagedObjectContext *managedObjectContext, NSArray *managedObjects);
44 |
45 | typedef void (^DCTManagedObjectContextCompletionBlock) (void);
46 |
47 | typedef void (^DCTFetchRequestCallbackBlock) (NSArray *fetchedObjects, NSError *error);
48 | typedef void (^DCTFetchRequestObjectCallbackBlock) (id fetchedObject, NSError *error);
49 |
50 | @interface NSManagedObjectContext (DCTAsynchronousTasks)
51 |
52 | /// @name Asynchronous Task
53 |
54 | - (void)dct_asynchronousTaskWithWorkBlock:(DCTManagedObjectContextBlock)workBlock;
55 |
56 | - (void)dct_asynchronousTaskWithWorkBlock:(DCTManagedObjectContextBlock)workBlock
57 | completionBlock:(DCTManagedObjectContextBlock)completionBlock;
58 |
59 | - (void)dct_asynchronousTaskWithCallbackQueue:(dispatch_queue_t)queue
60 | workBlock:(DCTManagedObjectContextBlock)workBlock;
61 |
62 | - (void)dct_asynchronousTaskWithCallbackQueue:(dispatch_queue_t)queue
63 | workBlock:(DCTManagedObjectContextBlock)workBlock
64 | completionBlock:(DCTManagedObjectContextBlock)completionBlock;
65 |
66 |
67 |
68 |
69 | /// @name Asynchronous Task with Object
70 |
71 | - (void)dct_asynchronousTaskWithObject:(NSManagedObject *)object
72 | workBlock:(DCTManagedObjectContextObjectBlock)workBlock;
73 |
74 | - (void)dct_asynchronousTaskWithObject:(NSManagedObject *)object
75 | workBlock:(DCTManagedObjectContextObjectBlock)workBlock
76 | completionBlock:(DCTManagedObjectContextCompletionBlock)completionBlock;
77 |
78 | - (void)dct_asynchronousTaskWithObject:(NSManagedObject *)object
79 | callbackQueue:(dispatch_queue_t)queue
80 | workBlock:(DCTManagedObjectContextObjectBlock)workBlock;
81 |
82 | - (void)dct_asynchronousTaskWithObject:(NSManagedObject *)object
83 | callbackQueue:(dispatch_queue_t)queue
84 | workBlock:(DCTManagedObjectContextObjectBlock)workBlock
85 | completionBlock:(DCTManagedObjectContextCompletionBlock)completionBlock;
86 |
87 |
88 |
89 |
90 | /// @name Asynchronous Task with Objects
91 |
92 | - (void)dct_asynchronousTaskWithObjects:(NSArray *)objects
93 | workBlock:(DCTManagedObjectContextObjectsBlock)workBlock;
94 |
95 | - (void)dct_asynchronousTaskWithObjects:(NSArray *)objects
96 | workBlock:(DCTManagedObjectContextObjectsBlock)workBlock
97 | completionBlock:(DCTManagedObjectContextCompletionBlock)completionBlock;
98 |
99 | - (void)dct_asynchronousTaskWithObjects:(NSArray *)objects
100 | callbackQueue:(dispatch_queue_t)queue
101 | workBlock:(DCTManagedObjectContextObjectsBlock)workBlock;
102 |
103 | - (void)dct_asynchronousTaskWithObjects:(NSArray *)objects
104 | callbackQueue:(dispatch_queue_t)queue
105 | workBlock:(DCTManagedObjectContextObjectsBlock)workBlock
106 | completionBlock:(DCTManagedObjectContextCompletionBlock)completionBlock;
107 |
108 |
109 | /// @name Asynchronous Fetching
110 |
111 |
112 | - (void)dct_asynchronousFetchRequest:(NSFetchRequest *)fetchRequest
113 | withCallbackBlock:(DCTFetchRequestCallbackBlock)callbackBlock;
114 |
115 | - (void)dct_asynchronousFetchRequest:(NSFetchRequest *)fetchRequest
116 | withCallbackQueue:(dispatch_queue_t)callbackQueue
117 | block:(DCTFetchRequestCallbackBlock)callbackBlock;
118 |
119 | @end
120 |
--------------------------------------------------------------------------------
/Readme.textile:
--------------------------------------------------------------------------------
1 | h1. DCTCoreData
2 |
3 | DCTCoreData is my collection of extensions to Apple's Core Data framework.
4 |
5 | *2.0* Code is now written for ARC, and works with iOS 4.3-style ARC.
6 |
7 | *1.3* New API for data fetching.
8 |
9 | *1.2* New API for automated setup.
10 |
11 | *1.1* Moves the location of all of the classes and renames NSFetchRequest+DCTInitMethods.h/m to NSFetchRequest+DCTExtras.h/m so you may need to jiggle things about when updating.
12 |
13 | h2. Features
14 |
15 | * Convenience methods for fetching from the managed object context
16 | * Automated creation of managed objects from an NSDictionary representation
17 | * A category to handle the ordering of related objects
18 | * Asynchronous tasks and fetching with blocks
19 | * Convenience methods for asynchronously fetching from the managed object context
20 |
21 | h3. NSManagedObjectContext (DCTDataFetching)
22 |
23 | Fetching from the context the way it always should have been! Lots of methods to ease the pain of fetching objects from a managed object context.
24 |
25 | Also includes an easy way to insert a new object. This will likely be moved to a separate category in the future.
26 |
27 | h3. NSManagedObject (DCTAutomatedSetup)
28 |
29 | Category to enable a subclass of NSManagedObject to conform to the DCTManagedObjectAutomatedSetup protocol and take a dictionary to generate its values.
30 |
31 | There are a number of methods subclasses can implement that will aid the setup process, I talk about these on "my blog post (DCTCoreData: DCTManagedObjectAutomatedSetup)":http://danieltull.co.uk/blog/2010/09/30/dctcoredata-dctmanagedobjectautomatedsetup/.
32 |
33 | h3. NSManagedObjectContext (DCTAsynchronousTasks)
34 |
35 | Adds methods to perform tasks off the main thread using GCD queues.
36 |
37 | The first set allow you to pass a block, in which you can access the threaded managed object context, to perform the task in another queue.
38 |
39 | The second set allow you to execute a fetch request on another GCD queue, which will call the given block when done with any objects fetched and an error if there is one. This method returns objects managed in the managed object context called on.
40 |
41 | h3. NSManagedObjectContext (DCTAsynchronousDataFetching)
42 |
43 | Similar to the DCTDataFetching category on NSManagedObjectContext, but performed using the asynchronous fetch from the DCTAsynchronousTasks category.
44 |
45 | h2. Branch Structure
46 |
47 | There is a new branch structure for DCTCoreData 2.0, *master* and *demo*. Unlike previous versions, *master* is now the branch to use as a submodule.
48 |
49 | h3. master
50 |
51 | The master branch contains the code and should be used if you want to add these extensions as a git submodule in other projects. It will only contain the class files themselves without the Xcode project or example classes. This is preferable as it will keep your directories clean of any code which is unnecessary to your working project.
52 |
53 | To add this project as a submodule you should run the following from inside your project's git repository:
54 |
55 | bc. git submodule add git://github.com/danielctull/DCTCoreData.git
56 |
57 | To keep up to date with the latest changes `cd` into the directory that contains this submodule and pull the newest changes as usual:
58 |
59 | bc. git pull origin
60 |
61 | h3. demo
62 |
63 | This contains an Xcode project that demonstrates the code and is the branch to use to see how to use the code. The demo branch contains a submodule reference to the master branch to bring in the library classes.
64 |
65 | To clone the demo branch, while also pulling in any necessary submodules run the following command:
66 |
67 | bc. git clone -b demo --recursive git://github.com/danielctull/DCTCoreData.git
68 |
69 | When changing to the demo branch you will need to run through the following set of commands:
70 |
71 | bc. git checkout demo
72 | git submodule init
73 | git submodule update
74 |
75 | After these you will see the example project and the library code will be in a sub-directory.
76 |
77 | h3. Artefacts
78 |
79 | Sometimes, there may be artefacts left over when switching from demo to master. These are files that are ignored by git and are easily cleaned up by running
80 |
81 | bc. git clean -dxf
82 |
83 | h2. Examples
84 |
85 | Examples of some of these features can be found in the iPhone app delegate.
86 |
87 | h2. License
88 |
89 | Copyright (C) 2010 Daniel Tull. All rights reserved.
90 |
91 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
92 |
93 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
94 |
95 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
96 |
97 | * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
98 |
99 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/DCTCoreData/NSManagedObjectContext+DCTDataFetching.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObjectContext+DCTDataFetching.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 16.09.2009.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSManagedObjectContext+DCTDataFetching.h"
38 | #import "NSFetchRequest+DCTExtras.h"
39 |
40 | @implementation NSManagedObjectContext (DCTDataFetching)
41 |
42 | #pragma mark -
43 | #pragma mark Fetching Multiple Objects
44 |
45 | - (NSArray *)dct_fetchObjectsForEntityName:(NSString *)entityName {
46 |
47 | return [self dct_fetchObjectsForEntityName:entityName
48 | predicate:nil
49 | sortDescriptors:nil
50 | batchSize:DCTFetchBatchSizeNil];
51 | }
52 |
53 | - (NSArray *)dct_fetchObjectsForEntityName:(NSString *)entityName
54 | predicate:(NSPredicate *)predicate {
55 |
56 | return [self dct_fetchObjectsForEntityName:entityName
57 | predicate:predicate
58 | sortDescriptors:nil
59 | batchSize:DCTFetchBatchSizeNil];
60 | }
61 |
62 | - (NSArray *)dct_fetchObjectsForEntityName:(NSString *)entityName
63 | predicate:(NSPredicate *)predicate
64 | sortDescriptors:(NSArray *)sortDescriptors {
65 |
66 | return [self dct_fetchObjectsForEntityName:entityName
67 | predicate:predicate
68 | sortDescriptors:sortDescriptors
69 | batchSize:DCTFetchBatchSizeNil];
70 | }
71 |
72 | - (NSArray *)dct_fetchObjectsForEntityName:(NSString *)entityName
73 | sortDescriptors:(NSArray *)sortDescriptors {
74 |
75 | return [self dct_fetchObjectsForEntityName:entityName
76 | predicate:nil
77 | sortDescriptors:sortDescriptors
78 | batchSize:DCTFetchBatchSizeNil];
79 | }
80 |
81 | // The one method that does the heavy lifting:
82 | - (NSArray *)dct_fetchObjectsForEntityName:(NSString *)entityName
83 | predicate:(NSPredicate *)predicate
84 | sortDescriptors:(NSArray *)sortDescriptors
85 | batchSize:(NSUInteger)batchSize {
86 |
87 | NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:self];
88 |
89 | NSFetchRequest *request = [[NSFetchRequest alloc] dct_initWithEntity:entity
90 | predicate:predicate
91 | sortDescriptors:sortDescriptors
92 | batchSize:batchSize];
93 |
94 | NSError *error = nil;
95 |
96 | NSArray *fetchResult = [self executeFetchRequest:request error:&error];
97 |
98 | if (error) {
99 | NSLog(@"DCTDataFetching: Error fetching objects. %@", error);
100 | return nil;
101 | }
102 |
103 | return fetchResult;
104 | }
105 |
106 | #pragma mark -
107 | #pragma mark Fetching Single Objects
108 |
109 | - (id)dct_fetchAnyObjectForEntityName:(NSString *)entityName {
110 |
111 | return [self dct_fetchFirstObjectForEntityName:entityName
112 | predicate:nil
113 | sortDescriptors:nil];
114 | }
115 |
116 | - (id)dct_fetchAnyObjectForEntityName:(NSString *)entityName
117 | predicate:(NSPredicate *)predicate {
118 |
119 | return [self dct_fetchFirstObjectForEntityName:entityName
120 | predicate:predicate
121 | sortDescriptors:nil];
122 | }
123 |
124 | - (id)dct_fetchFirstObjectForEntityName:(NSString *)entityName
125 | sortDescriptors:(NSArray *)sortDescriptors {
126 |
127 | return [self dct_fetchFirstObjectForEntityName:entityName
128 | predicate:nil
129 | sortDescriptors:sortDescriptors];
130 | }
131 |
132 | - (id)dct_fetchFirstObjectForEntityName:(NSString *)entityName
133 | predicate:(NSPredicate *)predicate
134 | sortDescriptors:(NSArray *)sortDescriptors {
135 |
136 | NSArray *results = [self dct_fetchObjectsForEntityName:entityName
137 | predicate:predicate
138 | sortDescriptors:sortDescriptors
139 | batchSize:DCTFetchBatchSizeNil];
140 |
141 | if ([results count] < 1) return nil;
142 |
143 | return [results objectAtIndex:0];
144 | }
145 |
146 | #pragma mark -
147 | #pragma mark Inserting New Objects
148 |
149 | - (id)dct_insertNewObjectForEntityName:(NSString *)entityName {
150 | return [NSEntityDescription insertNewObjectForEntityForName:entityName inManagedObjectContext:self];
151 | }
152 |
153 | @end
154 |
--------------------------------------------------------------------------------
/DCTCoreData/Automated Setup/NSManagedObject+DCTAutomatedSetup.h:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObject+DCTAutomatedSetup.h
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 11.08.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 |
39 | @interface NSManagedObject (DCTAutomatedSetup)
40 |
41 |
42 | /**
43 | Setup method to get the managed object inserted into the given context, from the given dictionary.
44 |
45 | Call this on the managed object class you wish to setup.
46 |
47 | This will recursively go through the dictionary, if a nested dictionary exists it will try to find
48 | a relationship for the key, and set up that as a core data object using the nested dictionary.
49 |
50 | Override this method to handle the setup manually if you wish.
51 |
52 | @param dictionary The dictionary used to represent the managed object's data.
53 | @param moc The managed object context the resulting managed object should be inserted to.
54 |
55 | @return A managed object or nil if the setup process fails.
56 | */
57 |
58 | + (id)dct_objectFromDictionary:(NSDictionary *)dictionary insertIntoManagedObjectContext:(NSManagedObjectContext *)moc;
59 |
60 | /**
61 | Sets up the object from the given dictionary.
62 |
63 | If you already have an object that represents the dictionary, you can call this to run through the same
64 | setup proceedure as the class method.
65 |
66 | This will recursively go through the dictionary, if a nested dictionary exists it will try to find
67 | a relationship for the key, and set up that as a core data object using the nested dictionary.
68 |
69 | @param dictionary The dictionary used to represent the managed object's data.
70 |
71 | @return YES if the setup suceeded, NO otherwise.
72 | */
73 |
74 | - (BOOL)dct_setupFromDictionary:(NSDictionary *)dictionary;
75 |
76 | /**
77 | You can override this method to manually store values from the dictionary for the key.
78 |
79 | By default this method does the following:
80 |
81 | 1. Calls +dct_convertValue:toCorrectTypeForKey: to perform any conversion needed
82 | 2. If the value is an array, it will loop through each object calling this method with the object and the key
83 | 3. If key is a modelled attribute of the receiver, calls -setValue:forKey:
84 | 4. If key is a modelled relationship it will get a managed object for that relationship
85 | 5. If key is a modelled to-one it will set the created managed object for the relationship
86 | 6. If key is a modelled to-many it will add the created managed object to the set for the relationship
87 |
88 | @param value The value for the given key in the setup dictionary
89 | @param key The key from the setup dictionary. This will be the mapped key, if there is a mapping.
90 |
91 | @return YES if setting the value succeeded, NO if it failed.
92 | */
93 | - (BOOL)dct_setSerializedValue:(id)value forKey:(NSString *)key;
94 |
95 | @end
96 |
97 |
98 |
99 |
100 | /**
101 | Any object that wants the ability to have its setup automated MUST conform to
102 | this protocol. It needn't implement any of the methods for it, but it must
103 | declare that it conforms to this protocol.
104 | */
105 | @protocol DCTManagedObjectAutomatedSetup
106 | @optional
107 |
108 |
109 | /**
110 | Add this method if the core data entity name differs to the class.
111 |
112 | If this method does not exist, the class name is used as the enity name.
113 | */
114 | + (NSString *)dct_entityName;
115 |
116 | /**
117 | Give the keys for the attributes to check for equality showing two managed objects are the same.
118 |
119 | If not implemented, the setup will try to locate an attribute named like so:
120 |
121 | Last camel-cased word of entity name, lowercased, plus "ID" on the end.
122 | Examples:
123 | An entity "Person" will lead to an attribute of name "personID".
124 | An entity "DTPerson" will lead to an attribute of name "personID".
125 | An entity "DTTwitterPerson" will lead to an attribute of name "personID".
126 |
127 | Implement this method if the unique attribute(s) for the object are not named in this fashion.
128 | */
129 | + (NSArray *)dct_uniqueKeys;
130 |
131 | /**
132 | Another option to convert the value in the dictionary to the correct type needed for the Core Data model.
133 | */
134 | + (id)dct_convertValue:(id)value toCorrectTypeForKey:(NSString *)key;
135 |
136 | /**
137 | This is an important method that should probably be implemented. Yuo need to return a dictionary
138 | of remote keys to local keys. For example if the remote key is "updated_at" and the key for in
139 | the model is "updatedAt", you need to provide a dictionary like so:
140 |
141 | {
142 | "updated_at" => "updatedAt";
143 | }
144 |
145 | The automated setup will then do the neccessary conversion to make sure the remote keys and
146 | local keys align.
147 |
148 | **WARNING** It is sometimes necesary to convert the local name to remote name, thus it can in
149 | certain cases look up a key using the value. Thus if you have two remote keys going to the same
150 | local key, problems will likely occur. In most usage I doubt this can happen, but I may change
151 | how I get this information in future.
152 |
153 | */
154 | + (NSDictionary *)dct_mappingFromRemoteNamesToLocalNames;
155 | @end
156 |
--------------------------------------------------------------------------------
/DCTCoreData/Automated Setup/NSManagedObject+DCTAutomatedSync.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObject+DCTAutomatedSync.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 20.09.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSManagedObject+DCTAutomatedSync.h"
38 | #import "NSManagedObject+DCTExtras.h"
39 | #import "NSAttributeDescription+DCTObjectCheck.h"
40 | #import "NSDictionary+DCTKeyForObject.h"
41 |
42 | BOOL const DCTManagedObjectAutomatedSyncLogInformationMessages = YES;
43 | BOOL const DCTManagedObjectAutomatedSyncLogWarningMessages = YES;
44 | BOOL const DCTManagedObjectAutomatedSyncLogErrorMessages = YES;
45 |
46 |
47 | @interface NSManagedObject (DCTAutomatedSyncInternal)
48 | - (NSDate *)dctAutomatedSyncInternal_localUpdatedDate;
49 | - (NSDate *)dctAutomatedSyncInternal_updatedDateInDictionary:(NSDictionary *)dictionary;
50 | - (NSString *)dctAutomatedSyncInternal_lastUpdatedDateKey;
51 | @end
52 |
53 | @implementation NSManagedObject (DCTAutomatedSync)
54 |
55 | - (void)dct_syncWithDictionary:(NSDictionary *)dictionary {
56 |
57 | if (![self conformsToProtocol:@protocol(DCTManagedObjectAutomatedSync)]) {
58 | if (DCTManagedObjectAutomatedSyncLogErrorMessages)
59 | NSLog(@"DCTAutomatedSync !!!!! (%@) Does not conform to DCTManagedObjectAutomatedSync.", NSStringFromClass([self class]));
60 | return;
61 | }
62 |
63 | NSManagedObject *syncSelf = (NSManagedObject *)self;
64 |
65 | DCTManagedObjectAutomatedSyncStatus syncStatus = DCTManagedObjectAutomatedSyncStatusNil;
66 |
67 | if ([syncSelf respondsToSelector:@selector(dct_syncStatusForDictionary:)])
68 | syncStatus = [syncSelf dct_syncStatusForDictionary:dictionary];
69 |
70 | if (syncStatus == DCTManagedObjectAutomatedSyncStatusNil) {
71 |
72 | NSDate *localUpdatedDate = [self dctAutomatedSyncInternal_localUpdatedDate];
73 | NSDate *remoteUpdatedDate = [self dctAutomatedSyncInternal_updatedDateInDictionary:dictionary];
74 |
75 | if (!localUpdatedDate || !remoteUpdatedDate) {
76 | if (DCTManagedObjectAutomatedSyncLogErrorMessages)
77 | NSLog(@"DCTAutomatedSync !!!!! (%@) Cannot determine sync status.", NSStringFromClass([self class]));
78 | return;
79 | }
80 |
81 | NSComparisonResult comparisonResult = [localUpdatedDate compare:remoteUpdatedDate];
82 |
83 | if (comparisonResult == NSOrderedSame)
84 | syncStatus = DCTManagedObjectAutomatedSyncStatusNone;
85 |
86 | else if (comparisonResult == NSOrderedAscending)
87 | syncStatus = DCTManagedObjectAutomatedSyncStatusDown;
88 |
89 | else if (comparisonResult == NSOrderedDescending)
90 | syncStatus = DCTManagedObjectAutomatedSyncStatusUp;
91 |
92 | }
93 |
94 | if (syncStatus == DCTManagedObjectAutomatedSyncStatusUp) {
95 |
96 | if (DCTManagedObjectAutomatedSyncLogInformationMessages)
97 | NSLog(@"DCTAutomatedSync (%@) Sync status up", NSStringFromClass([self class]));
98 |
99 | if ([syncSelf respondsToSelector:@selector(dct_synchroniseToSource)])
100 | [syncSelf dct_synchroniseToSource];
101 | return;
102 | }
103 |
104 | if (syncStatus == DCTManagedObjectAutomatedSyncStatusDown) {
105 |
106 | if (DCTManagedObjectAutomatedSyncLogInformationMessages)
107 | NSLog(@"DCTAutomatedSync (%@) Sync status down", NSStringFromClass([self class]));
108 |
109 | [self dct_setupFromDictionary:dictionary];
110 | return;
111 | }
112 |
113 | if (DCTManagedObjectAutomatedSyncLogInformationMessages)
114 | NSLog(@"DCTAutomatedSync (%@) Sync status same", NSStringFromClass([self class]));
115 |
116 | }
117 |
118 | @end
119 |
120 | @implementation NSManagedObject (DCTAutomatedSyncInternal)
121 |
122 | - (NSDate *)dctAutomatedSyncInternal_localUpdatedDate {
123 |
124 | NSString *key = [self dctAutomatedSyncInternal_lastUpdatedDateKey];
125 |
126 | if (!key) return nil;
127 |
128 | NSAttributeDescription *attribute = [self dct_attributeDescriptionForKey:key];
129 |
130 | if (!attribute || ![attribute dct_isClassValid:[NSDate class]]) return nil;
131 |
132 | return [self valueForKey:key];
133 | }
134 |
135 | - (NSDate *)dctAutomatedSyncInternal_updatedDateInDictionary:(NSDictionary *)dictionary {
136 |
137 | NSString *key = [self dctAutomatedSyncInternal_lastUpdatedDateKey];
138 |
139 | if (!key) return nil;
140 |
141 | NSDate *date = [dictionary objectForKey:key];
142 |
143 | Class syncClass = [(id)self class];
144 |
145 | if (!date && [syncClass respondsToSelector:@selector(dct_mappingFromRemoteNamesToLocalNames)]) {
146 |
147 | NSDictionary *mapping = [syncClass dct_mappingFromRemoteNamesToLocalNames];
148 |
149 | key = [mapping dct_keyForObject:key];
150 |
151 | date = [dictionary objectForKey:key];
152 |
153 | if (!date) return nil;
154 | }
155 |
156 | if (![date isKindOfClass:[NSDate class]]) {
157 |
158 | if (![syncClass respondsToSelector:@selector(dct_convertValue:toCorrectTypeForKey:)]) return nil;
159 |
160 | date = [syncClass dct_convertValue:date toCorrectTypeForKey:key];
161 |
162 | if (![date isKindOfClass:[NSDate class]]) return nil;
163 | }
164 |
165 | return date;
166 | }
167 |
168 |
169 | - (NSString *)dctAutomatedSyncInternal_lastUpdatedDateKey {
170 |
171 | if ([self respondsToSelector:@selector(dct_lastUpdatedDateKey)])
172 | return [(id)self dct_lastUpdatedDateKey];
173 |
174 | return nil;
175 | }
176 |
177 | @end
178 |
--------------------------------------------------------------------------------
/DCTCoreData/Asynchronous/NSManagedObjectContext+DCTAsynchronousDataFetching.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObjectContext+DCTAsynchronousDataFetching.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 4.12.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSManagedObjectContext+DCTAsynchronousDataFetching.h"
38 | #import "NSFetchRequest+DCTExtras.h"
39 |
40 | @implementation NSManagedObjectContext (DCTAsynchronousDataFetching)
41 |
42 | #pragma mark -
43 | #pragma mark Fetching Multiple Objects
44 |
45 | - (void)dct_asynchronousObjectsForEntityName:(NSString *)entityName
46 | callbackBlock:(DCTFetchRequestCallbackBlock)callbackBlock {
47 |
48 | [self dct_asynchronousObjectsForEntityName:entityName
49 | predicate:nil
50 | sortDescriptors:nil
51 | batchSize:DCTFetchBatchSizeNil
52 | callbackBlock:callbackBlock];
53 | }
54 |
55 | - (void)dct_asynchronousObjectsForEntityName:(NSString *)entityName
56 | predicate:(NSPredicate *)predicate
57 | callbackBlock:(DCTFetchRequestCallbackBlock)callbackBlock {
58 |
59 | [self dct_asynchronousObjectsForEntityName:entityName
60 | predicate:predicate
61 | sortDescriptors:nil
62 | batchSize:DCTFetchBatchSizeNil
63 | callbackBlock:callbackBlock];
64 | }
65 |
66 | - (void)dct_asynchronousObjectsForEntityName:(NSString *)entityName
67 | predicate:(NSPredicate *)predicate
68 | sortDescriptors:(NSArray *)sortDescriptors
69 | callbackBlock:(DCTFetchRequestCallbackBlock)callbackBlock {
70 |
71 | [self dct_asynchronousObjectsForEntityName:entityName
72 | predicate:predicate
73 | sortDescriptors:sortDescriptors
74 | batchSize:DCTFetchBatchSizeNil
75 | callbackBlock:callbackBlock];
76 | }
77 |
78 | - (void)dct_asynchronousObjectsForEntityName:(NSString *)entityName
79 | sortDescriptors:(NSArray *)sortDescriptors
80 | callbackBlock:(DCTFetchRequestCallbackBlock)callbackBlock {
81 |
82 | [self dct_asynchronousObjectsForEntityName:entityName
83 | predicate:nil
84 | sortDescriptors:sortDescriptors
85 | batchSize:DCTFetchBatchSizeNil
86 | callbackBlock:callbackBlock];
87 | }
88 |
89 | - (void)dct_asynchronousObjectsForEntityName:(NSString *)entityName
90 | predicate:(NSPredicate *)predicate
91 | sortDescriptors:(NSArray *)sortDescriptors
92 | batchSize:(NSUInteger)batchSize
93 | callbackBlock:(DCTFetchRequestCallbackBlock)callbackBlock {
94 |
95 | NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:self];
96 |
97 | NSFetchRequest *request = [[NSFetchRequest alloc] dct_initWithEntity:entity
98 | predicate:predicate
99 | sortDescriptors:sortDescriptors
100 | batchSize:batchSize];
101 |
102 | [self dct_asynchronousFetchRequest:request
103 | withCallbackBlock:callbackBlock];
104 |
105 | }
106 |
107 | #pragma mark -
108 | #pragma mark Fetching Single Objects
109 |
110 | - (void)dct_asynchronousObjectForEntityName:(NSString *)entityName
111 | callbackBlock:(DCTFetchRequestObjectCallbackBlock)callbackBlock {
112 |
113 | [self dct_asynchronousObjectForEntityName:entityName
114 | predicate:nil
115 | sortDescriptors:nil
116 | batchSize:DCTFetchBatchSizeNil
117 | callbackBlock:callbackBlock];
118 | }
119 |
120 | - (void)dct_asynchronousObjectForEntityName:(NSString *)entityName
121 | predicate:(NSPredicate *)predicate
122 | callbackBlock:(DCTFetchRequestObjectCallbackBlock)callbackBlock {
123 |
124 | [self dct_asynchronousObjectForEntityName:entityName
125 | predicate:predicate
126 | sortDescriptors:nil
127 | batchSize:DCTFetchBatchSizeNil
128 | callbackBlock:callbackBlock];
129 | }
130 |
131 | - (void)dct_asynchronousObjectForEntityName:(NSString *)entityName
132 | predicate:(NSPredicate *)predicate
133 | sortDescriptors:(NSArray *)sortDescriptors
134 | callbackBlock:(DCTFetchRequestObjectCallbackBlock)callbackBlock {
135 |
136 | [self dct_asynchronousObjectForEntityName:entityName
137 | predicate:predicate
138 | sortDescriptors:sortDescriptors
139 | batchSize:DCTFetchBatchSizeNil
140 | callbackBlock:callbackBlock];
141 | }
142 |
143 | - (void)dct_asynchronousObjectForEntityName:(NSString *)entityName
144 | sortDescriptors:(NSArray *)sortDescriptors
145 | callbackBlock:(DCTFetchRequestObjectCallbackBlock)callbackBlock {
146 |
147 | [self dct_asynchronousObjectForEntityName:entityName
148 | predicate:nil
149 | sortDescriptors:sortDescriptors
150 | batchSize:DCTFetchBatchSizeNil
151 | callbackBlock:callbackBlock];
152 | }
153 |
154 | - (void)dct_asynchronousObjectForEntityName:(NSString *)entityName
155 | predicate:(NSPredicate *)predicate
156 | sortDescriptors:(NSArray *)sortDescriptors
157 | batchSize:(NSUInteger)batchSize
158 | callbackBlock:(DCTFetchRequestObjectCallbackBlock)callbackBlock {
159 |
160 | DCTFetchRequestCallbackBlock block = ^(NSArray *fetchedObjects, NSError *error) {
161 |
162 | id object = nil;
163 | if ([fetchedObjects count] > 0) object = [fetchedObjects objectAtIndex:0];
164 |
165 | callbackBlock(object, error);
166 | };
167 |
168 | [self dct_asynchronousObjectsForEntityName:entityName
169 | predicate:predicate
170 | sortDescriptors:sortDescriptors
171 | batchSize:batchSize
172 | callbackBlock:block];
173 | }
174 |
175 | @end
176 |
--------------------------------------------------------------------------------
/DCTCoreData/Automated Setup/NSManagedObject+DCTAutomatedSetup.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObject+DCTAutomatedSetup.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 11.08.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import
38 | #import "NSEntityDescription+DCTObjectCheck.h"
39 | #import "NSAttributeDescription+DCTObjectCheck.h"
40 | #import "NSDictionary+DCTKeyForObject.h"
41 |
42 | /* Define these for logging problems:
43 |
44 | DCTManagedObjectAutomatedSetupLogStorageFailures
45 | DCTManagedObjectAutomatedSetupLogAutomaticPrimaryKeyUse
46 | DCTManagedObjectAutomatedSetupLogExtremeFailures
47 | */
48 |
49 |
50 | @interface NSManagedObject (DCTAutomatedSetupInternal)
51 |
52 | + (id)dctAutomatedSetupInternal_fetchObjectMatchingDictionary:(NSDictionary *)dictionary
53 | entity:(NSEntityDescription *)entity
54 | managedObjectContext:(NSManagedObjectContext *)moc;
55 |
56 | @end
57 |
58 | @implementation NSManagedObject (DCTAutomatedSetup)
59 |
60 | + (id)dct_objectFromDictionary:(NSDictionary *)dictionary
61 | insertIntoManagedObjectContext:(NSManagedObjectContext *)moc {
62 |
63 | if (![self conformsToProtocol:@protocol(DCTManagedObjectAutomatedSetup)])
64 | return nil;
65 |
66 | Class myself = (Class)self;
67 |
68 | NSManagedObject *object = nil;
69 |
70 | NSString *entityName = nil;
71 | if ([self respondsToSelector:@selector(dct_entityName)])
72 | entityName = [myself dct_entityName];
73 |
74 | if (!entityName)
75 | entityName = NSStringFromClass(myself);
76 |
77 | NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:moc];
78 |
79 | if (!object)
80 | object = [self dctAutomatedSetupInternal_fetchObjectMatchingDictionary:dictionary entity:entity managedObjectContext:moc];
81 |
82 | if (!object)
83 | object = [moc dct_insertNewObjectForEntityName:entityName];
84 |
85 |
86 | [object dct_setupFromDictionary:dictionary];
87 |
88 | return object;
89 | }
90 |
91 | - (BOOL)dct_setupFromDictionary:(NSDictionary *)dictionary {
92 |
93 | if (![self conformsToProtocol:@protocol(DCTManagedObjectAutomatedSetup)])
94 | return NO;
95 |
96 | Class selfclass = [self class];
97 |
98 | NSDictionary *mapping = nil;
99 |
100 | if ([[self class] respondsToSelector:@selector(dct_mappingFromRemoteNamesToLocalNames)])
101 | mapping = [selfclass dct_mappingFromRemoteNamesToLocalNames];
102 |
103 | for (__strong NSString *key in dictionary) {
104 |
105 | id object = [dictionary objectForKey:key];
106 |
107 | // convert the key to our local storage using the provide mapping
108 | if ([[mapping allKeys] containsObject:key])
109 | key = [mapping objectForKey:key];
110 |
111 | if (![self dct_setSerializedValue:object forKey:key]) {
112 |
113 | #if defined(DCTManagedObjectAutomatedSetupLogStorageFailures)
114 | NSLog(@"%@ (DCTManagedObjectAutomatedSetup): Didn't store key:%@ object:%@", NSStringFromClass([self class]), key, object);
115 | #endif
116 |
117 | }
118 |
119 | }
120 |
121 | return YES;
122 |
123 | }
124 |
125 | - (BOOL)dct_setSerializedValue:(id)object forKey:(NSString *)key {
126 |
127 | Class selfclass = [self class];
128 |
129 | // give the class a chance to convert the object
130 | if ([[self class] respondsToSelector:@selector(dct_convertValue:toCorrectTypeForKey:)] && ![object isKindOfClass:[NSNull class]]) {
131 | id returnedObject = [selfclass dct_convertValue:object toCorrectTypeForKey:key];
132 | if (returnedObject) object = returnedObject;
133 | }
134 |
135 |
136 | if ([object isKindOfClass:[NSArray class]]) {
137 | BOOL returnBool = NO;
138 |
139 | for (id o in (NSArray *)object) {
140 | if ([self dct_setSerializedValue:o forKey:key])
141 | returnBool = YES;
142 | }
143 | return returnBool;
144 | }
145 |
146 |
147 | NSEntityDescription *entity = [self entity];
148 | NSDictionary *attributesByName = [entity attributesByName];
149 |
150 | if ([[attributesByName allKeys] containsObject:key]) {
151 |
152 | NSAttributeDescription *attribute = [attributesByName objectForKey:key];
153 |
154 | if ([attribute dct_isObjectValid:object]) {
155 | [self setValue:object forKey:key];
156 | return YES;
157 | }
158 | }
159 |
160 |
161 | NSDictionary *relationshipsByName = [entity relationshipsByName];
162 |
163 | if ([[relationshipsByName allKeys] containsObject:key]) {
164 |
165 | NSRelationshipDescription *relationship = [relationshipsByName objectForKey:key];
166 | NSEntityDescription *destinationEntity = [relationship destinationEntity];
167 |
168 | // if it's a dictionary at this point, we'll try to create a managed object of the right class using the dictionary
169 | if ([object isKindOfClass:[NSDictionary class]]) {
170 | NSString *destinationClassName = [destinationEntity managedObjectClassName];
171 | Class destinationClass = NSClassFromString(destinationClassName);
172 | object = [destinationClass dct_objectFromDictionary:object insertIntoManagedObjectContext:[self managedObjectContext]];
173 | }
174 |
175 | BOOL isValid = [destinationEntity dct_isObjectValid:object];
176 |
177 | if (isValid) {
178 |
179 | if ([relationship isToMany]) {
180 |
181 | if ([object conformsToProtocol:@protocol(DCTOrderedObject)])
182 | [self dct_addOrderedObject:object forKey:key];
183 | else
184 | [self dct_addRelatedObject:object forKey:key];
185 |
186 | } else if (isValid)
187 | [self setValue:object forKey:key];
188 |
189 | return YES;
190 | }
191 | }
192 |
193 | return NO;
194 | }
195 |
196 | @end
197 |
198 | @implementation NSManagedObject (DCTAutomatedSetupInternal)
199 |
200 | + (id)dctAutomatedSetupInternal_fetchObjectMatchingDictionary:(NSDictionary *)dictionary
201 | entity:(NSEntityDescription *)entity
202 | managedObjectContext:(NSManagedObjectContext *)moc {
203 |
204 | Class myself = (Class)self;
205 |
206 | NSArray *localPrimaryKeys = nil;
207 |
208 | if ([self respondsToSelector:@selector(dct_uniqueKeys)])
209 | localPrimaryKeys = [myself dct_uniqueKeys];
210 |
211 | if (!localPrimaryKeys) {
212 | NSRange range = [[entity name] rangeOfCharacterFromSet:[NSCharacterSet uppercaseLetterCharacterSet] options:NSBackwardsSearch];
213 | NSString *localPrimaryKey = [[[[entity name] substringFromIndex:range.location] lowercaseString] stringByAppendingString:@"ID"];
214 | localPrimaryKeys = [NSArray arrayWithObject:localPrimaryKey];
215 |
216 | #if defined (DCTManagedObjectAutomatedSetupLogAutomaticPrimaryKeyUse)
217 | NSLog(@"%@ (DCTManagedObjectAutomatedSetup): Cannot determine primary keys, using '%@\'", NSStringFromClass([self class]), localPrimaryKey);
218 | #endif
219 |
220 | }
221 |
222 | for (NSString *localPrimaryKey in localPrimaryKeys) {
223 | if (![[[entity propertiesByName] allKeys] containsObject:localPrimaryKey]) {
224 |
225 | #if defined (DCTManagedObjectAutomatedSetupLogExtremeFailures)
226 | NSLog(@"!!!!! DCTManagedObjectAutomatedSetup: Cannot resolve a primary key for %@, so duplicate objects will not be found.", [entity name]);
227 | #endif
228 |
229 | return nil;
230 | }
231 | }
232 |
233 | NSMutableArray *predicates = [[NSMutableArray alloc] initWithCapacity:[localPrimaryKeys count]];
234 |
235 | for (NSString *localPrimaryKey in localPrimaryKeys) {
236 |
237 | NSString *remotePrimaryKey = nil;
238 |
239 | if ([[dictionary allKeys] containsObject:localPrimaryKey])
240 | remotePrimaryKey = localPrimaryKey;
241 |
242 | if ([self respondsToSelector:@selector(dct_mappingFromRemoteNamesToLocalNames)]) {
243 | NSDictionary *mapping = [myself dct_mappingFromRemoteNamesToLocalNames];
244 |
245 | if ([[mapping allValues] containsObject:localPrimaryKey]) {
246 | NSString *pKey = [mapping dct_keyForObject:localPrimaryKey];
247 | if (pKey) remotePrimaryKey = pKey;
248 | }
249 | }
250 |
251 | if (!remotePrimaryKey)
252 | remotePrimaryKey = @"id";
253 |
254 | id primaryKeyValue = [dictionary objectForKey:remotePrimaryKey];
255 |
256 | NSDictionary *attributesByName = [entity attributesByName];
257 | NSDictionary *relationshipsByName = [entity relationshipsByName];
258 |
259 | BOOL objectIsValid = NO;
260 |
261 | if ([[attributesByName allKeys] containsObject:localPrimaryKey]) {
262 | NSAttributeDescription *attribute = [attributesByName objectForKey:localPrimaryKey];
263 | objectIsValid = [attribute dct_isObjectValid:primaryKeyValue];
264 |
265 | } else if ([[relationshipsByName allKeys] containsObject:localPrimaryKey]) {
266 | NSRelationshipDescription *relationship = [relationshipsByName objectForKey:localPrimaryKey];
267 | NSEntityDescription *destinationEntity = [relationship destinationEntity];
268 | objectIsValid = [destinationEntity dct_isObjectValid:primaryKeyValue];
269 | }
270 |
271 | if (!objectIsValid && [self respondsToSelector:@selector(dct_convertValue:toCorrectTypeForKey:)])
272 | primaryKeyValue = [myself dct_convertValue:primaryKeyValue toCorrectTypeForKey:localPrimaryKey];
273 |
274 | if ([primaryKeyValue isKindOfClass:[NSString class]])
275 | primaryKeyValue = [primaryKeyValue stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];
276 |
277 | [predicates addObject:[NSPredicate dct_predicateWhereProperty:localPrimaryKey equals:primaryKeyValue]];
278 | }
279 |
280 | NSPredicate *predicate = [NSCompoundPredicate andPredicateWithSubpredicates:predicates];
281 |
282 | return [moc dct_fetchAnyObjectForEntityName:[entity name] predicate:predicate];
283 |
284 | }
285 |
286 | @end
287 |
--------------------------------------------------------------------------------
/DCTCoreData/Asynchronous/NSManagedObjectContext+DCTAsynchronousTasks.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObjectContext+DCTAsynchronousTasks.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 4.12.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSManagedObjectContext+DCTAsynchronousTasks.h"
38 | #import "NSManagedObjectContext+DCTExtras.h"
39 |
40 | @interface NSManagedObjectContext (DCTAsynchronousTasksInternal)
41 | - (void)dctAsynchronousTasksInternal_threadedContextDidSave:(NSNotification *)notification;
42 | - (BOOL)dctAsynchronousTasksInternal_raiseExceptionIfNotMainThread;
43 | @end
44 |
45 | @implementation NSManagedObjectContext (DCTAsynchronousTasks)
46 |
47 | #pragma mark -
48 | #pragma mark Modification methods
49 |
50 |
51 | - (void)dct_asynchronousTaskWithWorkBlock:(DCTManagedObjectContextBlock)workBlock {
52 | [self dct_asynchronousTaskWithWorkBlock:workBlock completionBlock:nil];
53 | }
54 |
55 |
56 |
57 |
58 | - (void)dct_asynchronousTaskWithWorkBlock:(DCTManagedObjectContextBlock)workBlock
59 | completionBlock:(DCTManagedObjectContextBlock)completionBlock {
60 |
61 | if ([self dctAsynchronousTasksInternal_raiseExceptionIfNotMainThread]) return;
62 |
63 | [self dct_asynchronousTaskWithCallbackQueue:dispatch_get_main_queue() workBlock:workBlock completionBlock:completionBlock];
64 | }
65 |
66 |
67 |
68 |
69 | - (void)dct_asynchronousTaskWithCallbackQueue:(dispatch_queue_t)queue
70 | workBlock:(DCTManagedObjectContextBlock)workBlock {
71 |
72 | [self dct_asynchronousTaskWithCallbackQueue:queue workBlock:workBlock completionBlock:nil];
73 | }
74 |
75 |
76 |
77 |
78 | - (void)dct_asynchronousTaskWithCallbackQueue:(dispatch_queue_t)queue
79 | workBlock:(DCTManagedObjectContextBlock)workBlock
80 | completionBlock:(DCTManagedObjectContextBlock)completionBlock {
81 |
82 | [self dct_asynchronousTaskWithObject:nil
83 | callbackQueue:queue
84 | workBlock:^(NSManagedObjectContext *moc, id mo) {
85 | workBlock(moc);
86 |
87 | } completionBlock:^{
88 | completionBlock(self);
89 | }];
90 | }
91 |
92 | #pragma mark -
93 | #pragma mark Modification methods with object
94 |
95 | - (void)dct_asynchronousTaskWithObject:(NSManagedObject *)object
96 | workBlock:(DCTManagedObjectContextObjectBlock)workBlock {
97 |
98 | [self dct_asynchronousTaskWithObject:object
99 | workBlock:workBlock
100 | completionBlock:nil];
101 | }
102 |
103 | - (void)dct_asynchronousTaskWithObject:(NSManagedObject *)object
104 | workBlock:(DCTManagedObjectContextObjectBlock)workBlock
105 | completionBlock:(DCTManagedObjectContextCompletionBlock)completionBlock {
106 |
107 | if ([self dctAsynchronousTasksInternal_raiseExceptionIfNotMainThread]) return;
108 |
109 | [self dct_asynchronousTaskWithObject:object
110 | callbackQueue:dispatch_get_main_queue()
111 | workBlock:workBlock
112 | completionBlock:completionBlock];
113 | }
114 |
115 | - (void)dct_asynchronousTaskWithObject:(NSManagedObject *)object
116 | callbackQueue:(dispatch_queue_t)queue
117 | workBlock:(DCTManagedObjectContextObjectBlock)workBlock {
118 |
119 | [self dct_asynchronousTaskWithObject:object
120 | callbackQueue:queue
121 | workBlock:workBlock
122 | completionBlock:nil];
123 | }
124 |
125 | - (void)dct_asynchronousTaskWithObject:(NSManagedObject *)object
126 | callbackQueue:(dispatch_queue_t)queue
127 | workBlock:(DCTManagedObjectContextObjectBlock)workBlock
128 | completionBlock:(DCTManagedObjectContextCompletionBlock)completionBlock {
129 |
130 |
131 | NSArray *array = nil;
132 | if (object) array = [NSArray arrayWithObject:object];
133 |
134 | [self dct_asynchronousTaskWithObjects:array
135 | callbackQueue:queue
136 | workBlock:^(NSManagedObjectContext *managedObjectContext, NSArray *managedObjects) {
137 |
138 | workBlock(managedObjectContext, [managedObjects objectAtIndex:0]);
139 |
140 | } completionBlock:completionBlock];
141 | }
142 |
143 |
144 |
145 | #pragma mark -
146 | #pragma mark Modification methods with objects
147 |
148 |
149 | - (void)dct_asynchronousTaskWithObjects:(NSArray *)objects
150 | workBlock:(DCTManagedObjectContextObjectsBlock)workBlock {
151 |
152 | [self dct_asynchronousTaskWithObjects:objects
153 | workBlock:workBlock
154 | completionBlock:nil];
155 | }
156 |
157 | - (void)dct_asynchronousTaskWithObjects:(NSArray *)objects
158 | workBlock:(DCTManagedObjectContextObjectsBlock)workBlock
159 | completionBlock:(DCTManagedObjectContextCompletionBlock)completionBlock {
160 |
161 | if ([self dctAsynchronousTasksInternal_raiseExceptionIfNotMainThread]) return;
162 |
163 | [self dct_asynchronousTaskWithObjects:objects
164 | callbackQueue:dispatch_get_main_queue()
165 | workBlock:workBlock
166 | completionBlock:completionBlock];
167 | }
168 |
169 | - (void)dct_asynchronousTaskWithObjects:(NSArray *)objects
170 | callbackQueue:(dispatch_queue_t)queue
171 | workBlock:(DCTManagedObjectContextObjectsBlock)workBlock {
172 |
173 | [self dct_asynchronousTaskWithObjects:objects
174 | callbackQueue:queue
175 | workBlock:workBlock
176 | completionBlock:nil];
177 | }
178 |
179 | - (void)dct_asynchronousTaskWithObjects:(NSArray *)objects
180 | callbackQueue:(dispatch_queue_t)queue
181 | workBlock:(DCTManagedObjectContextObjectsBlock)workBlock
182 | completionBlock:(DCTManagedObjectContextCompletionBlock)completionBlock {
183 |
184 | NSMutableArray *objectIDs = nil;
185 |
186 | if (objects) {
187 | objectIDs = [NSMutableArray arrayWithCapacity:[objects count]];
188 | for (NSManagedObject *mo in objects)
189 | [objectIDs addObject:[mo objectID]];
190 | }
191 |
192 | NSManagedObjectContext *threadedContext = [[NSManagedObjectContext alloc] init];
193 | [threadedContext setPersistentStoreCoordinator:[self persistentStoreCoordinator]];
194 |
195 | dispatch_queue_t asyncQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
196 |
197 | dispatch_async(asyncQueue, ^{
198 |
199 | NSArray *threadedObjects = nil;
200 | if (objectIDs) {
201 | NSMutableArray *array = [NSMutableArray arrayWithCapacity:[objectIDs count]];
202 | for (NSManagedObjectID *objectID in objectIDs)
203 | [array addObject:[threadedContext objectWithID:objectID]];
204 |
205 | threadedObjects = [NSArray arrayWithArray:array];
206 | }
207 |
208 | workBlock(threadedContext, threadedObjects);
209 |
210 | dispatch_async(queue, ^{
211 |
212 | NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
213 |
214 | [defaultCenter addObserver:self
215 | selector:@selector(dctAsynchronousTasksInternal_threadedContextDidSave:)
216 | name:NSManagedObjectContextDidSaveNotification
217 | object:threadedContext];
218 |
219 | if ([threadedContext hasChanges]) [threadedContext save:NULL];
220 |
221 | [defaultCenter removeObserver:self
222 | name:NSManagedObjectContextDidSaveNotification
223 | object:threadedContext];
224 |
225 |
226 | completionBlock();
227 | });
228 | });
229 |
230 | }
231 |
232 | #pragma mark -
233 | #pragma mark Fetch methods
234 |
235 | - (void)dct_asynchronousFetchRequest:(NSFetchRequest *)fetchRequest
236 | withCallbackBlock:(DCTFetchRequestCallbackBlock)callbackBlock {
237 |
238 | if ([self dctAsynchronousTasksInternal_raiseExceptionIfNotMainThread]) return;
239 |
240 | [self dct_asynchronousFetchRequest:fetchRequest
241 | withCallbackQueue:dispatch_get_main_queue()
242 | block:callbackBlock];
243 | }
244 |
245 | - (void)dct_asynchronousFetchRequest:(NSFetchRequest *)fetchRequest
246 | withCallbackQueue:(dispatch_queue_t)callbackQueue
247 | block:(DCTFetchRequestCallbackBlock)callbackBlock {
248 |
249 | NSManagedObjectContext *threadedContext = [[NSManagedObjectContext alloc] init];
250 | [threadedContext setPersistentStoreCoordinator:[self persistentStoreCoordinator]];
251 |
252 | dispatch_queue_t asyncQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
253 |
254 | dispatch_async(asyncQueue, ^{
255 |
256 | NSError *error = nil;
257 | NSArray *array = [threadedContext executeFetchRequest:fetchRequest error:&error];
258 |
259 | NSMutableArray *objectIDs = [NSMutableArray arrayWithCapacity:[array count]];
260 |
261 | for (NSManagedObject *mo in array)
262 | [objectIDs addObject:[mo objectID]];
263 |
264 | dispatch_async(callbackQueue, ^{
265 |
266 | NSMutableArray *returnedObjects = [NSMutableArray arrayWithCapacity:[objectIDs count]];
267 |
268 | for (NSManagedObjectID *objectID in objectIDs)
269 | [returnedObjects addObject:[self objectWithID:objectID]];
270 |
271 | callbackBlock([NSArray arrayWithArray:returnedObjects], error);
272 | });
273 |
274 | });
275 |
276 | }
277 |
278 |
279 | @end
280 |
281 | @implementation NSManagedObjectContext (DCTAsynchronousTasksInternal)
282 |
283 | - (BOOL)dctAsynchronousTasksInternal_raiseExceptionIfNotMainThread {
284 | if (![[NSThread currentThread] isEqual:[NSThread mainThread]]) {
285 | [[NSException exceptionWithName:@"DCTManagedObjectContextBackgroundingNotMainThreadException"
286 | reason:@"Calling to perform a background operation on something which isn't the main thread."
287 | userInfo:nil] raise];
288 | return YES;
289 | }
290 |
291 | return NO;
292 | }
293 |
294 | - (void)dctAsynchronousTasksInternal_threadedContextDidSave:(NSNotification *)notification {
295 | [self setMergePolicy:NSMergeByPropertyStoreTrumpMergePolicy];
296 | [self mergeChangesFromContextDidSaveNotification:notification];
297 | }
298 |
299 | @end
300 |
--------------------------------------------------------------------------------
/DCTCoreData/NSManagedObject+DCTOrdering.m:
--------------------------------------------------------------------------------
1 | /*
2 | NSManagedObject+DCTOrdering.m
3 | DCTCoreData
4 |
5 | Created by Daniel Tull on 14.08.2010.
6 |
7 |
8 |
9 | Copyright (C) 2010 Daniel Tull. All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | * Neither the name of the author nor the names of its contributors may be used
22 | to endorse or promote products derived from this software without specific
23 | prior written permission.
24 |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #import "NSManagedObject+DCTOrdering.h"
38 | #import "NSManagedObject+DCTRelatedObjects.h"
39 |
40 | NSComparisonResult (^compareOrderedObjects)(id obj1, id obj2) = ^(id obj1, id obj2) {
41 |
42 | if (![obj1 isKindOfClass:[NSManagedObject class]]
43 | || ![obj2 isKindOfClass:[NSManagedObject class]]
44 | || ![obj1 conformsToProtocol:@protocol(DCTOrderedObject)]
45 | || ![obj2 conformsToProtocol:@protocol(DCTOrderedObject)])
46 | return (NSComparisonResult)NSOrderedSame;
47 |
48 | NSManagedObject *man1 = (NSManagedObject *)obj1;
49 | NSManagedObject *man2 = (NSManagedObject *)obj2;
50 |
51 | return [man1.dctOrderedObjectIndex compare:man2.dctOrderedObjectIndex];
52 | };
53 |
54 | @interface NSManagedObject (DCTOrderingInternal)
55 | - (BOOL)dctOrderingInternal_containsRelationshipForKey:(NSString *)key;
56 | - (NSSet *)dctOrderingInternal_orderedObjectsSetForKey:(NSString *)key;
57 | - (NSInteger)dctOrderingInternal_setCountForKey:(NSString *)key;
58 |
59 | - (void)dctOrderingInternal_setNextOrderedObject:(NSManagedObject *)nextObject;
60 | - (NSManagedObject *)dctOrderingInternal_nextOrderedObject;
61 |
62 | - (void)dctOrderingInternal_setPreviousOrderedObject:(NSManagedObject *)nextObject;
63 | - (NSManagedObject *)dctOrderingInternal_previousOrderedObject;
64 | @end
65 |
66 | @implementation NSManagedObject (DCTOrdering)
67 |
68 |
69 | - (void)dct_addOrderedObject:(NSManagedObject *)object
70 | forKey:(NSString *)key {
71 |
72 | if (![self dctOrderingInternal_containsRelationshipForKey:key]) return;
73 |
74 | NSManagedObject *lastObject = [self dct_lastOrderedObjectForKey:key];
75 |
76 | if ([lastObject dctOrderingInternal_nextOrderedObject]) return;
77 |
78 | [lastObject dctOrderingInternal_setNextOrderedObject:object];
79 |
80 | object.dctOrderedObjectIndex = [NSNumber numberWithInteger:[lastObject.dctOrderedObjectIndex integerValue]+1];
81 |
82 | [self dct_addRelatedObject:object forKey:key];
83 | }
84 |
85 |
86 |
87 | - (void)dct_addOrderedObject:(NSManagedObject *)object
88 | forKey:(NSString *)key
89 | lastObject:(NSManagedObject *)last {
90 |
91 | if (![self dctOrderingInternal_containsRelationshipForKey:key]) return;
92 |
93 | // if the afterObject has a next object set, it's not the end so call the proper insert method
94 | if ([last dctOrderingInternal_nextOrderedObject])
95 | return [self dct_addOrderedObject:object forKey:key];
96 |
97 | NSUInteger insertionIndex = [last.dctOrderedObjectIndex integerValue] + 1;
98 |
99 | // if the set count is larger than the new object's insertion point, it's not the end so call the proper insert method
100 | if ([[self valueForKey:key] count] > insertionIndex)
101 | return [self dct_addOrderedObject:object forKey:key];
102 |
103 | object.dctOrderedObjectIndex = [NSNumber numberWithInteger:insertionIndex];
104 |
105 | [object dctOrderingInternal_setNextOrderedObject:last];
106 |
107 | [self dct_addRelatedObject:object forKey:key];
108 | }
109 |
110 |
111 | - (void)dct_insertOrderedObject:(NSManagedObject *)object
112 | atIndex:(NSUInteger)insertionIndex
113 | forKey:(NSString *)key {
114 |
115 | if (![self dctOrderingInternal_containsRelationshipForKey:key]) return;
116 |
117 | NSSet *set = [self dctOrderingInternal_orderedObjectsSetForKey:key];
118 |
119 | if ([set count] > 0) {
120 |
121 | NSArray *orderedObjects = [self dct_orderedObjectsForKey:key];
122 |
123 | if ([orderedObjects count] > insertionIndex) {
124 |
125 | NSRange range = NSMakeRange(insertionIndex, [orderedObjects count] - insertionIndex);
126 | NSArray *objectsAfter = [orderedObjects subarrayWithRange:range];
127 |
128 | for (NSManagedObject *o in objectsAfter)
129 | o.dctOrderedObjectIndex = [NSNumber numberWithInteger:[o.dctOrderedObjectIndex integerValue]+1];
130 |
131 | [object dctOrderingInternal_setNextOrderedObject:[orderedObjects objectAtIndex:insertionIndex]];
132 | }
133 |
134 | // work out the object before insert
135 | [object dctOrderingInternal_setPreviousOrderedObject:[orderedObjects objectAtIndex:insertionIndex - 1]];
136 | }
137 |
138 | object.dctOrderedObjectIndex = [NSNumber numberWithInteger:insertionIndex];
139 |
140 | [self dct_addRelatedObject:object forKey:key];
141 | }
142 |
143 |
144 |
145 | - (void)dct_removeOrderedObjectAtIndex:(NSUInteger)theIndex
146 | forKey:(NSString *)key {
147 |
148 | if (![self dctOrderingInternal_containsRelationshipForKey:key]) return;
149 |
150 | NSSet *set = [self dctOrderingInternal_orderedObjectsSetForKey:key];
151 |
152 | if ([set count] < theIndex) return;
153 |
154 |
155 | NSArray *orderedObjects = [self dct_orderedObjectsForKey:key];
156 |
157 | NSManagedObject *previous = [orderedObjects objectAtIndex:theIndex - 1];
158 |
159 | [previous dctOrderingInternal_setNextOrderedObject:nil];
160 |
161 | NSManagedObject *object = [orderedObjects objectAtIndex:theIndex];
162 |
163 | if ([orderedObjects count] > theIndex) {
164 |
165 | NSManagedObject *next = [orderedObjects objectAtIndex:theIndex + 1];
166 | [previous dctOrderingInternal_setNextOrderedObject:next];
167 |
168 | NSRange range = NSMakeRange(theIndex, [orderedObjects count] - theIndex);
169 | NSArray *objectsAfter = [orderedObjects subarrayWithRange:range];
170 |
171 | for (NSManagedObject *o in objectsAfter)
172 | o.dctOrderedObjectIndex = [NSNumber numberWithInteger:[o.dctOrderedObjectIndex integerValue] - 1];
173 | }
174 |
175 | [self dct_removeRelatedObject:object forKey:key];
176 | }
177 |
178 |
179 | - (void)dct_replaceOrderedObjectAtIndex:(NSUInteger)theIndex
180 | withObject:(NSManagedObject *)object
181 | forKey:(NSString *)key {
182 |
183 | if (![self dctOrderingInternal_containsRelationshipForKey:key]) return;
184 |
185 | NSManagedObject *objectToReplace = [self dct_orderedObjectAtIndex:theIndex forKey:key];
186 |
187 | object.dctOrderedObjectIndex = objectToReplace.dctOrderedObjectIndex;
188 |
189 | NSManagedObject *previous = [objectToReplace dctOrderingInternal_previousOrderedObject];
190 | NSManagedObject *next = [objectToReplace dctOrderingInternal_nextOrderedObject];
191 |
192 | [objectToReplace dctOrderingInternal_setNextOrderedObject:nil];
193 | [objectToReplace dctOrderingInternal_setPreviousOrderedObject:nil];
194 |
195 | [object dctOrderingInternal_setPreviousOrderedObject:previous];
196 | [object dctOrderingInternal_setNextOrderedObject:next];
197 |
198 | [self dct_replaceRelatedObject:objectToReplace withRelatedObject:object forKey:key];
199 | }
200 |
201 |
202 |
203 | - (NSManagedObject *)dct_orderedObjectAtIndex:(NSUInteger)theIndex
204 | forKey:(NSString *)key {
205 |
206 | NSArray *orderedObjects = [self dct_orderedObjectsForKey:key];
207 |
208 | if (!orderedObjects || [orderedObjects count] < theIndex) return nil;
209 |
210 | NSManagedObject *mo = [orderedObjects objectAtIndex:theIndex];
211 |
212 | if (![mo conformsToProtocol:@protocol(DCTOrderedObject)]) return nil;
213 |
214 | return (NSManagedObject *)mo;
215 | }
216 |
217 |
218 |
219 | - (NSArray *)dct_orderedObjectsForKey:(NSString *)key {
220 |
221 | NSSet *set = [self dctOrderingInternal_orderedObjectsSetForKey:key];
222 |
223 | if (!set) return nil;
224 |
225 | return [[set allObjects] sortedArrayUsingComparator:compareOrderedObjects];
226 | }
227 |
228 |
229 |
230 |
231 | - (NSManagedObject *)dct_lastOrderedObjectForKey:(NSString *)key {
232 |
233 | NSInteger count = [self dctOrderingInternal_setCountForKey:key];
234 |
235 | if (count == 0) return nil;
236 |
237 | return [self dct_orderedObjectAtIndex:count-1 forKey:key];
238 | }
239 |
240 |
241 |
242 | - (NSManagedObject *)dct_firstOrderedObjectForKey:(NSString *)key {
243 |
244 | if ([self dctOrderingInternal_setCountForKey:key] == 0) return nil;
245 |
246 | return [self dct_orderedObjectAtIndex:0 forKey:key];
247 | }
248 |
249 | @end
250 |
251 | @implementation NSManagedObject (DCTOrderingInternal)
252 |
253 | - (BOOL)dctOrderingInternal_containsRelationshipForKey:(NSString *)key {
254 | return [[[[self entity] relationshipsByName] allKeys] containsObject:key];
255 | }
256 |
257 |
258 | - (NSSet *)dctOrderingInternal_orderedObjectsSetForKey:(NSString *)key {
259 |
260 | if (![self dctOrderingInternal_containsRelationshipForKey:key]) return nil;
261 |
262 | return [self valueForKey:key];
263 | }
264 |
265 | - (NSInteger)dctOrderingInternal_setCountForKey:(NSString *)key {
266 | return [[self dctOrderingInternal_orderedObjectsSetForKey:key] count];
267 | }
268 |
269 | - (void)dctOrderingInternal_setNextOrderedObject:(NSManagedObject *)next {
270 |
271 | if (![self conformsToProtocol:@protocol(DCTOrderedObject)] || ![self respondsToSelector:@selector(setDctNextOrderedObject:)]) return;
272 |
273 | ((NSManagedObject *)self).dctNextOrderedObject = next;
274 | }
275 |
276 | - (NSManagedObject *)dctOrderingInternal_nextOrderedObject {
277 |
278 | if (![self conformsToProtocol:@protocol(DCTOrderedObject)] || ![self respondsToSelector:@selector(dctNextOrderedObject)]) return nil;
279 |
280 | return ((NSManagedObject *)self).dctNextOrderedObject;
281 | }
282 |
283 | - (void)dctOrderingInternal_setPreviousOrderedObject:(NSManagedObject *)previous {
284 |
285 | if (![self conformsToProtocol:@protocol(DCTOrderedObject)] || ![self respondsToSelector:@selector(setDctPreviousOrderedObject:)]) return;
286 |
287 | ((NSManagedObject *)self).dctPreviousOrderedObject = previous;
288 | }
289 |
290 | - (NSManagedObject *)dctOrderingInternal_previousOrderedObject {
291 |
292 | if (![self conformsToProtocol:@protocol(DCTOrderedObject)] || ![self respondsToSelector:@selector(dctPreviousOrderedObject)]) return nil;
293 |
294 | return ((NSManagedObject *)self).dctPreviousOrderedObject;
295 | }
296 |
297 |
298 | @end
299 |
--------------------------------------------------------------------------------
/DCTCoreData.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 2437B5FB15B9788A00750117 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F6EEDF158A442800CEDD41 /* Foundation.framework */; };
11 | 2437B60715B978A900750117 /* NSArray+DCTSortDescriptors.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF1A158A446E00CEDD41 /* NSArray+DCTSortDescriptors.m */; };
12 | 2437B60915B978A900750117 /* NSFetchedResultsController+DCTExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF1C158A446E00CEDD41 /* NSFetchedResultsController+DCTExtras.m */; };
13 | 2437B60B15B978A900750117 /* NSFetchRequest+DCTExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF1E158A446E00CEDD41 /* NSFetchRequest+DCTExtras.m */; };
14 | 2437B60D15B978A900750117 /* NSManagedObject+DCTExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF20158A446E00CEDD41 /* NSManagedObject+DCTExtras.m */; };
15 | 2437B60F15B978A900750117 /* NSManagedObject+DCTOrdering.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF22158A446E00CEDD41 /* NSManagedObject+DCTOrdering.m */; };
16 | 2437B61115B978A900750117 /* NSManagedObject+DCTRelatedObjects.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF24158A446E00CEDD41 /* NSManagedObject+DCTRelatedObjects.m */; };
17 | 2437B61315B978A900750117 /* NSManagedObjectContext+DCTDataFetching.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF26158A446E00CEDD41 /* NSManagedObjectContext+DCTDataFetching.m */; };
18 | 2437B61515B978A900750117 /* NSManagedObjectContext+DCTExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF28158A446E00CEDD41 /* NSManagedObjectContext+DCTExtras.m */; };
19 | 2437B61715B978A900750117 /* NSPredicate+DCTExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF2A158A446E00CEDD41 /* NSPredicate+DCTExtras.m */; };
20 | 2437B61915B978FC00750117 /* NSManagedObjectContext+DCTAsynchronousDataFetching.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF0A158A446E00CEDD41 /* NSManagedObjectContext+DCTAsynchronousDataFetching.m */; };
21 | 2437B61B15B978FC00750117 /* NSManagedObjectContext+DCTAsynchronousTasks.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF0C158A446E00CEDD41 /* NSManagedObjectContext+DCTAsynchronousTasks.m */; };
22 | 2437B61D15B978FC00750117 /* NSAttributeDescription+DCTObjectCheck.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF0F158A446E00CEDD41 /* NSAttributeDescription+DCTObjectCheck.m */; };
23 | 2437B61F15B978FC00750117 /* NSDictionary+DCTKeyForObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF11158A446E00CEDD41 /* NSDictionary+DCTKeyForObject.m */; };
24 | 2437B62115B978FC00750117 /* NSEntityDescription+DCTObjectCheck.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF13158A446E00CEDD41 /* NSEntityDescription+DCTObjectCheck.m */; };
25 | 2437B62315B978FC00750117 /* NSManagedObject+DCTAutomatedSetup.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF15158A446E00CEDD41 /* NSManagedObject+DCTAutomatedSetup.m */; };
26 | 2437B62515B978FC00750117 /* NSManagedObject+DCTAutomatedSync.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EF17158A446E00CEDD41 /* NSManagedObject+DCTAutomatedSync.m */; };
27 | 2437B62615B978FE00750117 /* NSManagedObjectContext+DCTAsynchronousDataFetching.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF09158A446E00CEDD41 /* NSManagedObjectContext+DCTAsynchronousDataFetching.h */; };
28 | 2437B62815B978FE00750117 /* NSManagedObjectContext+DCTAsynchronousTasks.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF0B158A446E00CEDD41 /* NSManagedObjectContext+DCTAsynchronousTasks.h */; };
29 | 2437B63015B978FE00750117 /* NSManagedObject+DCTAutomatedSetup.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF14158A446E00CEDD41 /* NSManagedObject+DCTAutomatedSetup.h */; };
30 | 2437B63215B978FE00750117 /* NSManagedObject+DCTAutomatedSync.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF16158A446E00CEDD41 /* NSManagedObject+DCTAutomatedSync.h */; };
31 | 2437B63415B9793400750117 /* NSArray+DCTSortDescriptors.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF19158A446E00CEDD41 /* NSArray+DCTSortDescriptors.h */; };
32 | 2437B63615B9793400750117 /* NSFetchedResultsController+DCTExtras.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF1B158A446E00CEDD41 /* NSFetchedResultsController+DCTExtras.h */; };
33 | 2437B63815B9793400750117 /* NSFetchRequest+DCTExtras.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF1D158A446E00CEDD41 /* NSFetchRequest+DCTExtras.h */; };
34 | 2437B63A15B9793400750117 /* NSManagedObject+DCTExtras.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF1F158A446E00CEDD41 /* NSManagedObject+DCTExtras.h */; };
35 | 2437B63C15B9793400750117 /* NSManagedObject+DCTOrdering.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF21158A446E00CEDD41 /* NSManagedObject+DCTOrdering.h */; };
36 | 2437B63E15B9793400750117 /* NSManagedObject+DCTRelatedObjects.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF23158A446E00CEDD41 /* NSManagedObject+DCTRelatedObjects.h */; };
37 | 2437B64015B9793400750117 /* NSManagedObjectContext+DCTDataFetching.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF25158A446E00CEDD41 /* NSManagedObjectContext+DCTDataFetching.h */; };
38 | 2437B64215B9793400750117 /* NSManagedObjectContext+DCTExtras.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF27158A446E00CEDD41 /* NSManagedObjectContext+DCTExtras.h */; };
39 | 2437B64415B9793400750117 /* NSPredicate+DCTExtras.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF29158A446E00CEDD41 /* NSPredicate+DCTExtras.h */; };
40 | 2437B64615B9798E00750117 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F6EF06158A445F00CEDD41 /* CoreData.framework */; };
41 | 24C029A415B9831A009B1DE9 /* DCTCoreData.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EF18158A446E00CEDD41 /* DCTCoreData.h */; };
42 | 24F6EEEE158A442800CEDD41 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F6EEED158A442800CEDD41 /* SenTestingKit.framework */; };
43 | 24F6EEF1158A442900CEDD41 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F6EEDF158A442800CEDD41 /* Foundation.framework */; };
44 | 24F6EEFA158A442900CEDD41 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 24F6EEF8158A442900CEDD41 /* InfoPlist.strings */; };
45 | 24F6EEFD158A442900CEDD41 /* DCTCoreDataTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EEFC158A442900CEDD41 /* DCTCoreDataTests.m */; };
46 | /* End PBXBuildFile section */
47 |
48 | /* Begin PBXCopyFilesBuildPhase section */
49 | 2437B5F815B9788A00750117 /* CopyFiles */ = {
50 | isa = PBXCopyFilesBuildPhase;
51 | buildActionMask = 2147483647;
52 | dstPath = "include/${PRODUCT_NAME}";
53 | dstSubfolderSpec = 16;
54 | files = (
55 | 24C029A415B9831A009B1DE9 /* DCTCoreData.h in CopyFiles */,
56 | 2437B63615B9793400750117 /* NSFetchedResultsController+DCTExtras.h in CopyFiles */,
57 | 2437B63815B9793400750117 /* NSFetchRequest+DCTExtras.h in CopyFiles */,
58 | 2437B63A15B9793400750117 /* NSManagedObject+DCTExtras.h in CopyFiles */,
59 | 2437B63C15B9793400750117 /* NSManagedObject+DCTOrdering.h in CopyFiles */,
60 | 2437B62815B978FE00750117 /* NSManagedObjectContext+DCTAsynchronousTasks.h in CopyFiles */,
61 | 2437B63015B978FE00750117 /* NSManagedObject+DCTAutomatedSetup.h in CopyFiles */,
62 | 2437B63415B9793400750117 /* NSArray+DCTSortDescriptors.h in CopyFiles */,
63 | 2437B63215B978FE00750117 /* NSManagedObject+DCTAutomatedSync.h in CopyFiles */,
64 | 2437B64215B9793400750117 /* NSManagedObjectContext+DCTExtras.h in CopyFiles */,
65 | 2437B64415B9793400750117 /* NSPredicate+DCTExtras.h in CopyFiles */,
66 | 2437B64015B9793400750117 /* NSManagedObjectContext+DCTDataFetching.h in CopyFiles */,
67 | 2437B63E15B9793400750117 /* NSManagedObject+DCTRelatedObjects.h in CopyFiles */,
68 | 2437B62615B978FE00750117 /* NSManagedObjectContext+DCTAsynchronousDataFetching.h in CopyFiles */,
69 | );
70 | runOnlyForDeploymentPostprocessing = 0;
71 | };
72 | /* End PBXCopyFilesBuildPhase section */
73 |
74 | /* Begin PBXFileReference section */
75 | 2437B5FA15B9788A00750117 /* libDCTCoreData.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDCTCoreData.a; sourceTree = BUILT_PRODUCTS_DIR; };
76 | 24F6EEDF158A442800CEDD41 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
77 | 24F6EEEC158A442800CEDD41 /* DCTCoreDataTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DCTCoreDataTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
78 | 24F6EEED158A442800CEDD41 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
79 | 24F6EEF7158A442900CEDD41 /* DCTCoreDataTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "DCTCoreDataTests-Info.plist"; sourceTree = ""; };
80 | 24F6EEF9158A442900CEDD41 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
81 | 24F6EEFB158A442900CEDD41 /* DCTCoreDataTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DCTCoreDataTests.h; sourceTree = ""; };
82 | 24F6EEFC158A442900CEDD41 /* DCTCoreDataTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DCTCoreDataTests.m; sourceTree = ""; };
83 | 24F6EF06158A445F00CEDD41 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
84 | 24F6EF09158A446E00CEDD41 /* NSManagedObjectContext+DCTAsynchronousDataFetching.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObjectContext+DCTAsynchronousDataFetching.h"; sourceTree = ""; };
85 | 24F6EF0A158A446E00CEDD41 /* NSManagedObjectContext+DCTAsynchronousDataFetching.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObjectContext+DCTAsynchronousDataFetching.m"; sourceTree = ""; };
86 | 24F6EF0B158A446E00CEDD41 /* NSManagedObjectContext+DCTAsynchronousTasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObjectContext+DCTAsynchronousTasks.h"; sourceTree = ""; };
87 | 24F6EF0C158A446E00CEDD41 /* NSManagedObjectContext+DCTAsynchronousTasks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObjectContext+DCTAsynchronousTasks.m"; sourceTree = ""; };
88 | 24F6EF0E158A446E00CEDD41 /* NSAttributeDescription+DCTObjectCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSAttributeDescription+DCTObjectCheck.h"; sourceTree = ""; };
89 | 24F6EF0F158A446E00CEDD41 /* NSAttributeDescription+DCTObjectCheck.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSAttributeDescription+DCTObjectCheck.m"; sourceTree = ""; };
90 | 24F6EF10158A446E00CEDD41 /* NSDictionary+DCTKeyForObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+DCTKeyForObject.h"; sourceTree = ""; };
91 | 24F6EF11158A446E00CEDD41 /* NSDictionary+DCTKeyForObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+DCTKeyForObject.m"; sourceTree = ""; };
92 | 24F6EF12158A446E00CEDD41 /* NSEntityDescription+DCTObjectCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSEntityDescription+DCTObjectCheck.h"; sourceTree = ""; };
93 | 24F6EF13158A446E00CEDD41 /* NSEntityDescription+DCTObjectCheck.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSEntityDescription+DCTObjectCheck.m"; sourceTree = ""; };
94 | 24F6EF14158A446E00CEDD41 /* NSManagedObject+DCTAutomatedSetup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObject+DCTAutomatedSetup.h"; sourceTree = ""; };
95 | 24F6EF15158A446E00CEDD41 /* NSManagedObject+DCTAutomatedSetup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObject+DCTAutomatedSetup.m"; sourceTree = ""; };
96 | 24F6EF16158A446E00CEDD41 /* NSManagedObject+DCTAutomatedSync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObject+DCTAutomatedSync.h"; sourceTree = ""; };
97 | 24F6EF17158A446E00CEDD41 /* NSManagedObject+DCTAutomatedSync.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObject+DCTAutomatedSync.m"; sourceTree = ""; };
98 | 24F6EF18158A446E00CEDD41 /* DCTCoreData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DCTCoreData.h; sourceTree = ""; };
99 | 24F6EF19158A446E00CEDD41 /* NSArray+DCTSortDescriptors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+DCTSortDescriptors.h"; sourceTree = ""; };
100 | 24F6EF1A158A446E00CEDD41 /* NSArray+DCTSortDescriptors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+DCTSortDescriptors.m"; sourceTree = ""; };
101 | 24F6EF1B158A446E00CEDD41 /* NSFetchedResultsController+DCTExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSFetchedResultsController+DCTExtras.h"; sourceTree = ""; };
102 | 24F6EF1C158A446E00CEDD41 /* NSFetchedResultsController+DCTExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSFetchedResultsController+DCTExtras.m"; sourceTree = ""; };
103 | 24F6EF1D158A446E00CEDD41 /* NSFetchRequest+DCTExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSFetchRequest+DCTExtras.h"; sourceTree = ""; };
104 | 24F6EF1E158A446E00CEDD41 /* NSFetchRequest+DCTExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSFetchRequest+DCTExtras.m"; sourceTree = ""; };
105 | 24F6EF1F158A446E00CEDD41 /* NSManagedObject+DCTExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObject+DCTExtras.h"; sourceTree = ""; };
106 | 24F6EF20158A446E00CEDD41 /* NSManagedObject+DCTExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObject+DCTExtras.m"; sourceTree = ""; };
107 | 24F6EF21158A446E00CEDD41 /* NSManagedObject+DCTOrdering.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObject+DCTOrdering.h"; sourceTree = ""; };
108 | 24F6EF22158A446E00CEDD41 /* NSManagedObject+DCTOrdering.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObject+DCTOrdering.m"; sourceTree = ""; };
109 | 24F6EF23158A446E00CEDD41 /* NSManagedObject+DCTRelatedObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObject+DCTRelatedObjects.h"; sourceTree = ""; };
110 | 24F6EF24158A446E00CEDD41 /* NSManagedObject+DCTRelatedObjects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObject+DCTRelatedObjects.m"; sourceTree = ""; };
111 | 24F6EF25158A446E00CEDD41 /* NSManagedObjectContext+DCTDataFetching.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObjectContext+DCTDataFetching.h"; sourceTree = ""; };
112 | 24F6EF26158A446E00CEDD41 /* NSManagedObjectContext+DCTDataFetching.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObjectContext+DCTDataFetching.m"; sourceTree = ""; };
113 | 24F6EF27158A446E00CEDD41 /* NSManagedObjectContext+DCTExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObjectContext+DCTExtras.h"; sourceTree = ""; };
114 | 24F6EF28158A446E00CEDD41 /* NSManagedObjectContext+DCTExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObjectContext+DCTExtras.m"; sourceTree = ""; };
115 | 24F6EF29158A446E00CEDD41 /* NSPredicate+DCTExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSPredicate+DCTExtras.h"; sourceTree = ""; };
116 | 24F6EF2A158A446E00CEDD41 /* NSPredicate+DCTExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSPredicate+DCTExtras.m"; sourceTree = ""; };
117 | /* End PBXFileReference section */
118 |
119 | /* Begin PBXFrameworksBuildPhase section */
120 | 2437B5F715B9788A00750117 /* Frameworks */ = {
121 | isa = PBXFrameworksBuildPhase;
122 | buildActionMask = 2147483647;
123 | files = (
124 | 2437B64615B9798E00750117 /* CoreData.framework in Frameworks */,
125 | 2437B5FB15B9788A00750117 /* Foundation.framework in Frameworks */,
126 | );
127 | runOnlyForDeploymentPostprocessing = 0;
128 | };
129 | 24F6EEE8158A442800CEDD41 /* Frameworks */ = {
130 | isa = PBXFrameworksBuildPhase;
131 | buildActionMask = 2147483647;
132 | files = (
133 | 24F6EEEE158A442800CEDD41 /* SenTestingKit.framework in Frameworks */,
134 | 24F6EEF1158A442900CEDD41 /* Foundation.framework in Frameworks */,
135 | );
136 | runOnlyForDeploymentPostprocessing = 0;
137 | };
138 | /* End PBXFrameworksBuildPhase section */
139 |
140 | /* Begin PBXGroup section */
141 | 24F6EED1158A442800CEDD41 = {
142 | isa = PBXGroup;
143 | children = (
144 | 24F6EEE1158A442800CEDD41 /* DCTCoreData */,
145 | 24F6EEF5158A442900CEDD41 /* DCTCoreDataTests */,
146 | 24F6EEDE158A442800CEDD41 /* Frameworks */,
147 | 24F6EEDD158A442800CEDD41 /* Products */,
148 | );
149 | sourceTree = "";
150 | };
151 | 24F6EEDD158A442800CEDD41 /* Products */ = {
152 | isa = PBXGroup;
153 | children = (
154 | 24F6EEEC158A442800CEDD41 /* DCTCoreDataTests.octest */,
155 | 2437B5FA15B9788A00750117 /* libDCTCoreData.a */,
156 | );
157 | name = Products;
158 | sourceTree = "";
159 | };
160 | 24F6EEDE158A442800CEDD41 /* Frameworks */ = {
161 | isa = PBXGroup;
162 | children = (
163 | 24F6EF06158A445F00CEDD41 /* CoreData.framework */,
164 | 24F6EEDF158A442800CEDD41 /* Foundation.framework */,
165 | 24F6EEED158A442800CEDD41 /* SenTestingKit.framework */,
166 | );
167 | name = Frameworks;
168 | sourceTree = "";
169 | };
170 | 24F6EEE1158A442800CEDD41 /* DCTCoreData */ = {
171 | isa = PBXGroup;
172 | children = (
173 | 24F6EF18158A446E00CEDD41 /* DCTCoreData.h */,
174 | 24F6EF08158A446E00CEDD41 /* Asynchronous */,
175 | 24F6EF0D158A446E00CEDD41 /* Automated Setup */,
176 | 24F6EF19158A446E00CEDD41 /* NSArray+DCTSortDescriptors.h */,
177 | 24F6EF1A158A446E00CEDD41 /* NSArray+DCTSortDescriptors.m */,
178 | 24F6EF1B158A446E00CEDD41 /* NSFetchedResultsController+DCTExtras.h */,
179 | 24F6EF1C158A446E00CEDD41 /* NSFetchedResultsController+DCTExtras.m */,
180 | 24F6EF1D158A446E00CEDD41 /* NSFetchRequest+DCTExtras.h */,
181 | 24F6EF1E158A446E00CEDD41 /* NSFetchRequest+DCTExtras.m */,
182 | 24F6EF1F158A446E00CEDD41 /* NSManagedObject+DCTExtras.h */,
183 | 24F6EF20158A446E00CEDD41 /* NSManagedObject+DCTExtras.m */,
184 | 24F6EF21158A446E00CEDD41 /* NSManagedObject+DCTOrdering.h */,
185 | 24F6EF22158A446E00CEDD41 /* NSManagedObject+DCTOrdering.m */,
186 | 24F6EF23158A446E00CEDD41 /* NSManagedObject+DCTRelatedObjects.h */,
187 | 24F6EF24158A446E00CEDD41 /* NSManagedObject+DCTRelatedObjects.m */,
188 | 24F6EF25158A446E00CEDD41 /* NSManagedObjectContext+DCTDataFetching.h */,
189 | 24F6EF26158A446E00CEDD41 /* NSManagedObjectContext+DCTDataFetching.m */,
190 | 24F6EF27158A446E00CEDD41 /* NSManagedObjectContext+DCTExtras.h */,
191 | 24F6EF28158A446E00CEDD41 /* NSManagedObjectContext+DCTExtras.m */,
192 | 24F6EF29158A446E00CEDD41 /* NSPredicate+DCTExtras.h */,
193 | 24F6EF2A158A446E00CEDD41 /* NSPredicate+DCTExtras.m */,
194 | );
195 | path = DCTCoreData;
196 | sourceTree = "";
197 | };
198 | 24F6EEF5158A442900CEDD41 /* DCTCoreDataTests */ = {
199 | isa = PBXGroup;
200 | children = (
201 | 24F6EEFB158A442900CEDD41 /* DCTCoreDataTests.h */,
202 | 24F6EEFC158A442900CEDD41 /* DCTCoreDataTests.m */,
203 | 24F6EEF6158A442900CEDD41 /* Supporting Files */,
204 | );
205 | path = DCTCoreDataTests;
206 | sourceTree = "";
207 | };
208 | 24F6EEF6158A442900CEDD41 /* Supporting Files */ = {
209 | isa = PBXGroup;
210 | children = (
211 | 24F6EEF7158A442900CEDD41 /* DCTCoreDataTests-Info.plist */,
212 | 24F6EEF8158A442900CEDD41 /* InfoPlist.strings */,
213 | );
214 | name = "Supporting Files";
215 | sourceTree = "";
216 | };
217 | 24F6EF08158A446E00CEDD41 /* Asynchronous */ = {
218 | isa = PBXGroup;
219 | children = (
220 | 24F6EF09158A446E00CEDD41 /* NSManagedObjectContext+DCTAsynchronousDataFetching.h */,
221 | 24F6EF0A158A446E00CEDD41 /* NSManagedObjectContext+DCTAsynchronousDataFetching.m */,
222 | 24F6EF0B158A446E00CEDD41 /* NSManagedObjectContext+DCTAsynchronousTasks.h */,
223 | 24F6EF0C158A446E00CEDD41 /* NSManagedObjectContext+DCTAsynchronousTasks.m */,
224 | );
225 | path = Asynchronous;
226 | sourceTree = "";
227 | };
228 | 24F6EF0D158A446E00CEDD41 /* Automated Setup */ = {
229 | isa = PBXGroup;
230 | children = (
231 | 24F6EF0E158A446E00CEDD41 /* NSAttributeDescription+DCTObjectCheck.h */,
232 | 24F6EF0F158A446E00CEDD41 /* NSAttributeDescription+DCTObjectCheck.m */,
233 | 24F6EF10158A446E00CEDD41 /* NSDictionary+DCTKeyForObject.h */,
234 | 24F6EF11158A446E00CEDD41 /* NSDictionary+DCTKeyForObject.m */,
235 | 24F6EF12158A446E00CEDD41 /* NSEntityDescription+DCTObjectCheck.h */,
236 | 24F6EF13158A446E00CEDD41 /* NSEntityDescription+DCTObjectCheck.m */,
237 | 24F6EF14158A446E00CEDD41 /* NSManagedObject+DCTAutomatedSetup.h */,
238 | 24F6EF15158A446E00CEDD41 /* NSManagedObject+DCTAutomatedSetup.m */,
239 | 24F6EF16158A446E00CEDD41 /* NSManagedObject+DCTAutomatedSync.h */,
240 | 24F6EF17158A446E00CEDD41 /* NSManagedObject+DCTAutomatedSync.m */,
241 | );
242 | path = "Automated Setup";
243 | sourceTree = "";
244 | };
245 | /* End PBXGroup section */
246 |
247 | /* Begin PBXNativeTarget section */
248 | 2437B5F915B9788A00750117 /* DCTCoreData */ = {
249 | isa = PBXNativeTarget;
250 | buildConfigurationList = 2437B60315B9788A00750117 /* Build configuration list for PBXNativeTarget "DCTCoreData" */;
251 | buildPhases = (
252 | 2437B5F815B9788A00750117 /* CopyFiles */,
253 | 2437B5F615B9788A00750117 /* Sources */,
254 | 2437B5F715B9788A00750117 /* Frameworks */,
255 | );
256 | buildRules = (
257 | );
258 | dependencies = (
259 | );
260 | name = DCTCoreData;
261 | productName = DCTCoreData;
262 | productReference = 2437B5FA15B9788A00750117 /* libDCTCoreData.a */;
263 | productType = "com.apple.product-type.library.static";
264 | };
265 | 24F6EEEB158A442800CEDD41 /* DCTCoreDataTests */ = {
266 | isa = PBXNativeTarget;
267 | buildConfigurationList = 24F6EF03158A442900CEDD41 /* Build configuration list for PBXNativeTarget "DCTCoreDataTests" */;
268 | buildPhases = (
269 | 24F6EEE7158A442800CEDD41 /* Sources */,
270 | 24F6EEE8158A442800CEDD41 /* Frameworks */,
271 | 24F6EEE9158A442800CEDD41 /* Resources */,
272 | 24F6EEEA158A442800CEDD41 /* ShellScript */,
273 | );
274 | buildRules = (
275 | );
276 | dependencies = (
277 | );
278 | name = DCTCoreDataTests;
279 | productName = DCTCoreDataTests;
280 | productReference = 24F6EEEC158A442800CEDD41 /* DCTCoreDataTests.octest */;
281 | productType = "com.apple.product-type.bundle";
282 | };
283 | /* End PBXNativeTarget section */
284 |
285 | /* Begin PBXProject section */
286 | 24F6EED3158A442800CEDD41 /* Project object */ = {
287 | isa = PBXProject;
288 | attributes = {
289 | LastUpgradeCheck = 0500;
290 | ORGANIZATIONNAME = "Daniel Tull";
291 | };
292 | buildConfigurationList = 24F6EED6158A442800CEDD41 /* Build configuration list for PBXProject "DCTCoreData" */;
293 | compatibilityVersion = "Xcode 3.2";
294 | developmentRegion = English;
295 | hasScannedForEncodings = 0;
296 | knownRegions = (
297 | en,
298 | );
299 | mainGroup = 24F6EED1158A442800CEDD41;
300 | productRefGroup = 24F6EEDD158A442800CEDD41 /* Products */;
301 | projectDirPath = "";
302 | projectRoot = "";
303 | targets = (
304 | 2437B5F915B9788A00750117 /* DCTCoreData */,
305 | 24F6EEEB158A442800CEDD41 /* DCTCoreDataTests */,
306 | );
307 | };
308 | /* End PBXProject section */
309 |
310 | /* Begin PBXResourcesBuildPhase section */
311 | 24F6EEE9158A442800CEDD41 /* Resources */ = {
312 | isa = PBXResourcesBuildPhase;
313 | buildActionMask = 2147483647;
314 | files = (
315 | 24F6EEFA158A442900CEDD41 /* InfoPlist.strings in Resources */,
316 | );
317 | runOnlyForDeploymentPostprocessing = 0;
318 | };
319 | /* End PBXResourcesBuildPhase section */
320 |
321 | /* Begin PBXShellScriptBuildPhase section */
322 | 24F6EEEA158A442800CEDD41 /* ShellScript */ = {
323 | isa = PBXShellScriptBuildPhase;
324 | buildActionMask = 2147483647;
325 | files = (
326 | );
327 | inputPaths = (
328 | );
329 | outputPaths = (
330 | );
331 | runOnlyForDeploymentPostprocessing = 0;
332 | shellPath = /bin/sh;
333 | shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n";
334 | };
335 | /* End PBXShellScriptBuildPhase section */
336 |
337 | /* Begin PBXSourcesBuildPhase section */
338 | 2437B5F615B9788A00750117 /* Sources */ = {
339 | isa = PBXSourcesBuildPhase;
340 | buildActionMask = 2147483647;
341 | files = (
342 | 2437B60715B978A900750117 /* NSArray+DCTSortDescriptors.m in Sources */,
343 | 2437B60915B978A900750117 /* NSFetchedResultsController+DCTExtras.m in Sources */,
344 | 2437B60B15B978A900750117 /* NSFetchRequest+DCTExtras.m in Sources */,
345 | 2437B60D15B978A900750117 /* NSManagedObject+DCTExtras.m in Sources */,
346 | 2437B60F15B978A900750117 /* NSManagedObject+DCTOrdering.m in Sources */,
347 | 2437B61115B978A900750117 /* NSManagedObject+DCTRelatedObjects.m in Sources */,
348 | 2437B61315B978A900750117 /* NSManagedObjectContext+DCTDataFetching.m in Sources */,
349 | 2437B61515B978A900750117 /* NSManagedObjectContext+DCTExtras.m in Sources */,
350 | 2437B61715B978A900750117 /* NSPredicate+DCTExtras.m in Sources */,
351 | 2437B61915B978FC00750117 /* NSManagedObjectContext+DCTAsynchronousDataFetching.m in Sources */,
352 | 2437B61B15B978FC00750117 /* NSManagedObjectContext+DCTAsynchronousTasks.m in Sources */,
353 | 2437B61D15B978FC00750117 /* NSAttributeDescription+DCTObjectCheck.m in Sources */,
354 | 2437B61F15B978FC00750117 /* NSDictionary+DCTKeyForObject.m in Sources */,
355 | 2437B62115B978FC00750117 /* NSEntityDescription+DCTObjectCheck.m in Sources */,
356 | 2437B62315B978FC00750117 /* NSManagedObject+DCTAutomatedSetup.m in Sources */,
357 | 2437B62515B978FC00750117 /* NSManagedObject+DCTAutomatedSync.m in Sources */,
358 | );
359 | runOnlyForDeploymentPostprocessing = 0;
360 | };
361 | 24F6EEE7158A442800CEDD41 /* Sources */ = {
362 | isa = PBXSourcesBuildPhase;
363 | buildActionMask = 2147483647;
364 | files = (
365 | 24F6EEFD158A442900CEDD41 /* DCTCoreDataTests.m in Sources */,
366 | );
367 | runOnlyForDeploymentPostprocessing = 0;
368 | };
369 | /* End PBXSourcesBuildPhase section */
370 |
371 | /* Begin PBXVariantGroup section */
372 | 24F6EEF8158A442900CEDD41 /* InfoPlist.strings */ = {
373 | isa = PBXVariantGroup;
374 | children = (
375 | 24F6EEF9158A442900CEDD41 /* en */,
376 | );
377 | name = InfoPlist.strings;
378 | sourceTree = "";
379 | };
380 | /* End PBXVariantGroup section */
381 |
382 | /* Begin XCBuildConfiguration section */
383 | 2437B60415B9788A00750117 /* Debug */ = {
384 | isa = XCBuildConfiguration;
385 | buildSettings = {
386 | CLANG_CXX_LIBRARY = "libc++";
387 | DSTROOT = /tmp/DCTCoreData.dst;
388 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
389 | GCC_PREFIX_HEADER = "";
390 | IPHONEOS_DEPLOYMENT_TARGET = 5.0;
391 | OTHER_LDFLAGS = "-ObjC";
392 | PRODUCT_NAME = "$(TARGET_NAME)";
393 | SKIP_INSTALL = YES;
394 | };
395 | name = Debug;
396 | };
397 | 2437B60515B9788A00750117 /* Release */ = {
398 | isa = XCBuildConfiguration;
399 | buildSettings = {
400 | CLANG_CXX_LIBRARY = "libc++";
401 | DSTROOT = /tmp/DCTCoreData.dst;
402 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
403 | GCC_PREFIX_HEADER = "";
404 | IPHONEOS_DEPLOYMENT_TARGET = 5.0;
405 | OTHER_LDFLAGS = "-ObjC";
406 | PRODUCT_NAME = "$(TARGET_NAME)";
407 | SKIP_INSTALL = YES;
408 | };
409 | name = Release;
410 | };
411 | 24F6EEFE158A442900CEDD41 /* Debug */ = {
412 | isa = XCBuildConfiguration;
413 | buildSettings = {
414 | ALWAYS_SEARCH_USER_PATHS = NO;
415 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
416 | CLANG_ENABLE_OBJC_ARC = YES;
417 | CLANG_WARN_BOOL_CONVERSION = YES;
418 | CLANG_WARN_CONSTANT_CONVERSION = YES;
419 | CLANG_WARN_EMPTY_BODY = YES;
420 | CLANG_WARN_ENUM_CONVERSION = YES;
421 | CLANG_WARN_INT_CONVERSION = YES;
422 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
423 | COPY_PHASE_STRIP = NO;
424 | GCC_C_LANGUAGE_STANDARD = gnu99;
425 | GCC_DYNAMIC_NO_PIC = NO;
426 | GCC_OPTIMIZATION_LEVEL = 0;
427 | GCC_PREPROCESSOR_DEFINITIONS = (
428 | "DEBUG=1",
429 | "$(inherited)",
430 | );
431 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
432 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
433 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
434 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
435 | GCC_WARN_UNDECLARED_SELECTOR = YES;
436 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
437 | GCC_WARN_UNUSED_FUNCTION = YES;
438 | GCC_WARN_UNUSED_VARIABLE = YES;
439 | IPHONEOS_DEPLOYMENT_TARGET = 5.1;
440 | ONLY_ACTIVE_ARCH = YES;
441 | SDKROOT = iphoneos;
442 | };
443 | name = Debug;
444 | };
445 | 24F6EEFF158A442900CEDD41 /* Release */ = {
446 | isa = XCBuildConfiguration;
447 | buildSettings = {
448 | ALWAYS_SEARCH_USER_PATHS = NO;
449 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
450 | CLANG_ENABLE_OBJC_ARC = YES;
451 | CLANG_WARN_BOOL_CONVERSION = YES;
452 | CLANG_WARN_CONSTANT_CONVERSION = YES;
453 | CLANG_WARN_EMPTY_BODY = YES;
454 | CLANG_WARN_ENUM_CONVERSION = YES;
455 | CLANG_WARN_INT_CONVERSION = YES;
456 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
457 | COPY_PHASE_STRIP = YES;
458 | GCC_C_LANGUAGE_STANDARD = gnu99;
459 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
460 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
461 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
462 | GCC_WARN_UNDECLARED_SELECTOR = YES;
463 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
464 | GCC_WARN_UNUSED_FUNCTION = YES;
465 | GCC_WARN_UNUSED_VARIABLE = YES;
466 | IPHONEOS_DEPLOYMENT_TARGET = 5.1;
467 | SDKROOT = iphoneos;
468 | VALIDATE_PRODUCT = YES;
469 | };
470 | name = Release;
471 | };
472 | 24F6EF04158A442900CEDD41 /* Debug */ = {
473 | isa = XCBuildConfiguration;
474 | buildSettings = {
475 | FRAMEWORK_SEARCH_PATHS = (
476 | "\"$(SDKROOT)/Developer/Library/Frameworks\"",
477 | "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
478 | );
479 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
480 | GCC_PREFIX_HEADER = "DCTCoreData/DCTCoreData-Prefix.pch";
481 | INFOPLIST_FILE = "DCTCoreDataTests/DCTCoreDataTests-Info.plist";
482 | PRODUCT_NAME = "$(TARGET_NAME)";
483 | WRAPPER_EXTENSION = octest;
484 | };
485 | name = Debug;
486 | };
487 | 24F6EF05158A442900CEDD41 /* Release */ = {
488 | isa = XCBuildConfiguration;
489 | buildSettings = {
490 | FRAMEWORK_SEARCH_PATHS = (
491 | "\"$(SDKROOT)/Developer/Library/Frameworks\"",
492 | "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
493 | );
494 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
495 | GCC_PREFIX_HEADER = "DCTCoreData/DCTCoreData-Prefix.pch";
496 | INFOPLIST_FILE = "DCTCoreDataTests/DCTCoreDataTests-Info.plist";
497 | PRODUCT_NAME = "$(TARGET_NAME)";
498 | WRAPPER_EXTENSION = octest;
499 | };
500 | name = Release;
501 | };
502 | /* End XCBuildConfiguration section */
503 |
504 | /* Begin XCConfigurationList section */
505 | 2437B60315B9788A00750117 /* Build configuration list for PBXNativeTarget "DCTCoreData" */ = {
506 | isa = XCConfigurationList;
507 | buildConfigurations = (
508 | 2437B60415B9788A00750117 /* Debug */,
509 | 2437B60515B9788A00750117 /* Release */,
510 | );
511 | defaultConfigurationIsVisible = 0;
512 | defaultConfigurationName = Release;
513 | };
514 | 24F6EED6158A442800CEDD41 /* Build configuration list for PBXProject "DCTCoreData" */ = {
515 | isa = XCConfigurationList;
516 | buildConfigurations = (
517 | 24F6EEFE158A442900CEDD41 /* Debug */,
518 | 24F6EEFF158A442900CEDD41 /* Release */,
519 | );
520 | defaultConfigurationIsVisible = 0;
521 | defaultConfigurationName = Release;
522 | };
523 | 24F6EF03158A442900CEDD41 /* Build configuration list for PBXNativeTarget "DCTCoreDataTests" */ = {
524 | isa = XCConfigurationList;
525 | buildConfigurations = (
526 | 24F6EF04158A442900CEDD41 /* Debug */,
527 | 24F6EF05158A442900CEDD41 /* Release */,
528 | );
529 | defaultConfigurationIsVisible = 0;
530 | defaultConfigurationName = Release;
531 | };
532 | /* End XCConfigurationList section */
533 | };
534 | rootObject = 24F6EED3158A442800CEDD41 /* Project object */;
535 | }
536 |
--------------------------------------------------------------------------------