This repository has been archived by the owner on Jan 17, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 535375a
Showing
12 changed files
with
536 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2012 Mattt Thompson (http://mattt.me/) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
224 changes: 224 additions & 0 deletions
224
Project Templates/AFNetworking/AFIncrementalStore.xctemplate/TemplateInfo.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>Identifier</key> | ||
<string>com.afnetworking.template.project.AFIncrementalStore</string> | ||
<key>Ancestors</key> | ||
<array> | ||
<string>com.apple.dt.unit.cocoaTouchApplication</string> | ||
</array> | ||
<key>Kind</key> | ||
<string>Xcode.Xcode3.ProjectTemplateUnitKind</string> | ||
<key>Options</key> | ||
<array> | ||
<dict> | ||
<key>Default</key> | ||
<string>false</string> | ||
<key>Description</key> | ||
<string>Whether the application should use the Core Data framework for storage</string> | ||
<key>Identifier</key> | ||
<string>coreData</string> | ||
<key>Name</key> | ||
<string>Use Core Data</string> | ||
<key>SortOrder</key> | ||
<integer>1</integer> | ||
<key>Type</key> | ||
<string>checkbox</string> | ||
<key>Units</key> | ||
<dict> | ||
<key>true</key> | ||
<dict> | ||
<key>Definitions</key> | ||
<dict> | ||
<key>../Podfile:afincrementalstore</key> | ||
<string>pod "AFIncrementalStore"</string> | ||
|
||
<key>___PACKAGENAME___-Prefix.pch:objC:importCoreData</key> | ||
<string>#import <CoreData/CoreData.h></string> | ||
|
||
<key>___PACKAGENAMEASIDENTIFIER___.xcdatamodeld</key> | ||
<dict> | ||
<key>Path</key> | ||
<string>___PACKAGENAMEASIDENTIFIER___.xcdatamodeld</string> | ||
<key>Group</key> | ||
<string>Models</string> | ||
</dict> | ||
|
||
<key>___VARIABLE_classPrefix:identifier___AppDelegate.h:methods:coreData</key> | ||
<string>@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; | ||
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; | ||
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; | ||
- (void)saveContext; | ||
</string> | ||
<key>___VARIABLE_classPrefix:identifier___AppDelegate.m:applicationWillTerminate:comments</key> | ||
<string>// Saves changes in the application's managed object context before the application terminates. | ||
</string> | ||
<key>___VARIABLE_classPrefix:identifier___AppDelegate.m:applicationWillTerminate:save</key> | ||
<string>[self saveContext]; | ||
</string> | ||
<key>___VARIABLE_classPrefix:identifier___AppDelegate.m:coreData</key> | ||
<string>#pragma mark - Core Data | ||
- (void)saveContext { | ||
NSError *error = nil; | ||
NSManagedObjectContext *managedObjectContext = self.managedObjectContext; | ||
if (managedObjectContext) { | ||
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) { | ||
NSLog(@"Unresolved error %@, %@", error, [error userInfo]); | ||
abort(); | ||
} | ||
} | ||
} | ||
- (NSManagedObjectContext *)managedObjectContext { | ||
if (_managedObjectContext) { | ||
return _managedObjectContext; | ||
} | ||
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; | ||
if (coordinator) { | ||
_managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; | ||
[_managedObjectContext setPersistentStoreCoordinator:coordinator]; | ||
} | ||
return _managedObjectContext; | ||
} | ||
- (NSManagedObjectModel *)managedObjectModel { | ||
if (_managedObjectModel) { | ||
return _managedObjectModel; | ||
} | ||
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"___PACKAGENAMEASIDENTIFIER___" withExtension:@"momd"]; | ||
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; | ||
return _managedObjectModel; | ||
} | ||
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator { | ||
if (_persistentStoreCoordinator) { | ||
return _persistentStoreCoordinator; | ||
} | ||
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; | ||
AFIncrementalStore *incrementalStore = (AFIncrementalStore *)[_persistentStoreCoordinator addPersistentStoreWithType:[___PACKAGENAMEASIDENTIFIER___IncrementalStore type] configuration:nil URL:nil options:nil error:nil]; | ||
NSURL *applicationDocumentsDirectory = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; | ||
NSURL *storeURL = [applicationDocumentsDirectory URLByAppendingPathComponent:@"___PACKAGENAMEASIDENTIFIER___.sqlite"]; | ||
NSDictionary *options = @{ | ||
NSInferMappingModelAutomaticallyOption : @(YES), | ||
NSMigratePersistentStoresAutomaticallyOption: @(YES) | ||
}; | ||
NSError *error = nil; | ||
if (![incrementalStore.backingPersistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) { | ||
NSLog(@"Unresolved error %@, %@", error, [error userInfo]); | ||
abort(); | ||
} | ||
return _persistentStoreCoordinator; | ||
} | ||
</string> | ||
|
||
<key>Classes/___PACKAGENAMEASIDENTIFIER___APIClient.h</key> | ||
<dict> | ||
<key>Beginning</key> | ||
<string>#import "AFIncrementalStore.h" | ||
#import "AFRestClient.h" | ||
@interface ___PACKAGENAMEASIDENTIFIER___APIClient : AFRESTClient <AFIncrementalStoreHTTPClient> | ||
+ (___PACKAGENAMEASIDENTIFIER___APIClient *)sharedClient; | ||
</string> | ||
<key>End</key> | ||
<string>@end</string> | ||
<key>Group</key> | ||
<key>Networking</key> | ||
</dict> | ||
|
||
<key>Classes/___PACKAGENAMEASIDENTIFIER___APIClient.m:AFIncrementalStore</key> | ||
<string>#pragma mark - AFIncrementalStore | ||
- (id)representationOrArrayOfRepresentationsFromResponseObject:(id)responseObject { | ||
return responseObject; | ||
} | ||
- (NSDictionary *)attributesForRepresentation:(NSDictionary *)representation | ||
ofEntity:(NSEntityDescription *)entity | ||
fromResponse:(NSHTTPURLResponse *)response | ||
{ | ||
NSMutableDictionary *mutablePropertyValues = [[super attributesForRepresentation:representation ofEntity:entity fromResponse:response] mutableCopy]; | ||
// Customize the response object to fit the expected attribute keys and values | ||
return mutablePropertyValues; | ||
} | ||
- (BOOL)shouldFetchRemoteAttributeValuesForObjectWithID:(NSManagedObjectID *)objectID | ||
inManagedObjectContext:(NSManagedObjectContext *)context | ||
{ | ||
return NO; | ||
} | ||
- (BOOL)shouldFetchRemoteValuesForRelationship:(NSRelationshipDescription *)relationship | ||
forObjectWithID:(NSManagedObjectID *)objectID | ||
inManagedObjectContext:(NSManagedObjectContext *)context | ||
{ | ||
return NO; | ||
} | ||
</string> | ||
|
||
<key>Classes/___PACKAGENAMEASIDENTIFIER___IncrementalStore.h</key> | ||
<dict> | ||
<key>Path</key> | ||
<string>___PACKAGENAMEASIDENTIFIER___IncrementalStore.h</string> | ||
<key>Group</key> | ||
<string>Networking</string> | ||
</dict> | ||
|
||
<key>Classes/___PACKAGENAMEASIDENTIFIER___IncrementalStore.m</key> | ||
<dict> | ||
<key>Path</key> | ||
<string>___PACKAGENAMEASIDENTIFIER___IncrementalStore.m</string> | ||
<key>Group</key> | ||
<string>Networking</string> | ||
</dict> | ||
</dict> | ||
<key>Nodes</key> | ||
<array> | ||
<string>../Podfile:afincrementalstore</string> | ||
<string>___PACKAGENAMEASIDENTIFIER___.xcdatamodeld</string> | ||
<string>___VARIABLE_classPrefix:identifier___AppDelegate.h:methods:coreData</string> | ||
<string>___VARIABLE_classPrefix:identifier___AppDelegate.h:import:___PACKAGENAMEASIDENTIFIER___IncrementalStore.h</string> | ||
<string>___VARIABLE_classPrefix:identifier___AppDelegate.m:implementation:synthesize:managedObjectContext = _managedObjectContext</string> | ||
<string>___VARIABLE_classPrefix:identifier___AppDelegate.m:implementation:synthesize:managedObjectModel = _managedObjectModel</string> | ||
<string>___VARIABLE_classPrefix:identifier___AppDelegate.m:implementation:synthesize:persistentStoreCoordinator = _persistentStoreCoordinator</string> | ||
<string>___VARIABLE_classPrefix:identifier___AppDelegate.m:implementation:dealloc:_managedObjectContext</string> | ||
<string>___VARIABLE_classPrefix:identifier___AppDelegate.m:implementation:dealloc:_managedObjectModel</string> | ||
<string>___VARIABLE_classPrefix:identifier___AppDelegate.m:implementation:dealloc:_persistentStoreCoordinator</string> | ||
<string>___VARIABLE_classPrefix:identifier___AppDelegate.m:applicationWillTerminate:save</string> | ||
<string>___VARIABLE_classPrefix:identifier___AppDelegate.m:coreData</string> | ||
<string>___PACKAGENAME___-Prefix.pch:objC:importCoreData</string> | ||
<string>Classes/___PACKAGENAMEASIDENTIFIER___APIClient.m:AFIncrementalStore</string> | ||
<string>Classes/___PACKAGENAMEASIDENTIFIER___IncrementalStore.h</string> | ||
<string>Classes/___PACKAGENAMEASIDENTIFIER___IncrementalStore.m</string> | ||
</array> | ||
<key>Targets</key> | ||
<array> | ||
<dict> | ||
<key>Frameworks</key> | ||
<array> | ||
<string>CoreData</string> | ||
</array> | ||
</dict> | ||
</array> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</array> | ||
</dict> | ||
</plist> |
5 changes: 5 additions & 0 deletions
5
...FIncrementalStore.xctemplate/___PACKAGENAMEASIDENTIFIER___.xcdatamodeld/.xccurrentversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict/> | ||
</plist> |
4 changes: 4 additions & 0 deletions
4
...ACKAGENAMEASIDENTIFIER___.xcdatamodeld/___PACKAGENAMEASIDENTIFIER___.xcdatamodel/contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<model name="Test1.xcdatamodel" userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" macOSVersion="Automatic" iOSVersion="Automatic"> | ||
<elements/> | ||
</model> |
6 changes: 6 additions & 0 deletions
6
...FNetworking/AFIncrementalStore.xctemplate/___PACKAGENAMEASIDENTIFIER___IncrementalStore.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
#import "AFIncrementalStore.h" | ||
|
||
@interface ___PACKAGENAMEASIDENTIFIER___IncrementalStore : AFIncrementalStore | ||
|
||
@end |
22 changes: 22 additions & 0 deletions
22
...FNetworking/AFIncrementalStore.xctemplate/___PACKAGENAMEASIDENTIFIER___IncrementalStore.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#import "___PACKAGENAMEASIDENTIFIER___IncrementalStore.h" | ||
#import "___PACKAGENAMEASIDENTIFIER___APIClient.h" | ||
|
||
@implementation ___PACKAGENAMEASIDENTIFIER___IncrementalStore | ||
|
||
+ (void)initialize { | ||
[NSPersistentStoreCoordinator registerStoreClass:self forStoreType:[self type]]; | ||
} | ||
|
||
+ (NSString *)type { | ||
return NSStringFromClass(self); | ||
} | ||
|
||
+ (NSManagedObjectModel *)model { | ||
return [[NSManagedObjectModel alloc] initWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"___PACKAGENAMEASIDENTIFIER___" withExtension:@"xcdatamodeld"]]; | ||
} | ||
|
||
- (id <AFIncrementalStoreHTTPClient>)HTTPClient { | ||
return [___PACKAGENAMEASIDENTIFIER___APIClient sharedClient]; | ||
} | ||
|
||
@end |
93 changes: 93 additions & 0 deletions
93
Project Templates/AFNetworking/AFNetworking.xctemplate/TemplateInfo.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>Identifier</key> | ||
<string>com.afnetworking.template.project.AFNetworking</string> | ||
<key>Name</key> | ||
<string>AFNetworking Dependency</string> | ||
<key>Ancestors</key> | ||
<array> | ||
</array> | ||
<key>Definitions</key> | ||
<dict> | ||
<key>../Podfile:afnetworking</key> | ||
<string>pod "AFNetworking"</string> | ||
|
||
<key>___PACKAGENAME___-Prefix.pch:objC:importSystemConfiguration</key> | ||
<string>#import <SystemConfiguration/SystemConfiguration.h></string> | ||
<key>___PACKAGENAME___-Prefix.pch:objC:importCoreServices</key> | ||
<string>#import <MobileCoreServices/MobileCoreServices.h></string> | ||
|
||
<key>Classes/___PACKAGENAMEASIDENTIFIER___APIClient.h</key> | ||
<dict> | ||
<key>Beginning</key> | ||
<string>#import "AFHTTPClient.h" | ||
@interface ___PACKAGENAMEASIDENTIFIER___APIClient : AFHTTPClient | ||
+ (___PACKAGENAMEASIDENTIFIER___APIClient *)sharedClient; | ||
</string> | ||
<key>End</key> | ||
<string>@end</string> | ||
<key>Group</key> | ||
<key>Networking</key> | ||
</dict> | ||
|
||
<key>Classes/___PACKAGENAMEASIDENTIFIER___APIClient.m</key> | ||
<dict> | ||
<key>Beginning</key> | ||
<string>#import "___PACKAGENAMEASIDENTIFIER___APIClient.h" | ||
#import "AFJSONRequestOperation.h" | ||
static NSString * const k___PACKAGENAMEASIDENTIFIER___APIBaseURLString = @"<# API Base URL #>"; | ||
@implementation ___PACKAGENAMEASIDENTIFIER___APIClient | ||
+ (___PACKAGENAMEASIDENTIFIER___APIClient *)sharedClient { | ||
static ___PACKAGENAMEASIDENTIFIER___APIClient *_sharedClient = nil; | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
_sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:k___PACKAGENAMEASIDENTIFIER___APIBaseURLString]]; | ||
}); | ||
return _sharedClient; | ||
} | ||
- (id)initWithBaseURL:(NSURL *)url { | ||
self = [super initWithBaseURL:url]; | ||
if (!self) { | ||
return nil; | ||
} | ||
[self registerHTTPOperationClass:[AFJSONRequestOperation class]]; | ||
[self setDefaultHeader:@"Accept" value:@"application/json"]; | ||
return self; | ||
} | ||
</string> | ||
<key>End</key> | ||
<string>@end</string> | ||
<key>Group</key> | ||
<key>Networking</key> | ||
</dict> | ||
</dict> | ||
<key>Description</key> | ||
<string></string> | ||
<key>Kind</key> | ||
<string>Xcode.Xcode3.ProjectTemplateUnitKind</string> | ||
<key>Nodes</key> | ||
<array> | ||
<string>../Podfile:afnetworking</string> | ||
<string>___PACKAGENAME___-Prefix.pch:objC:importSystemConfiguration</string> | ||
<string>___PACKAGENAME___-Prefix.pch:objC:importCoreServices</string> | ||
<string>Classes/___PACKAGENAMEASIDENTIFIER___APIClient.h</string> | ||
<string>Classes/___PACKAGENAMEASIDENTIFIER___APIClient.m</string> | ||
</array> | ||
<key>Options</key> | ||
<array> | ||
</array> | ||
<key>SortOrder</key> | ||
<integer>1</integer> | ||
</dict> | ||
</plist> |
Oops, something went wrong.