Browse files

Remove all compile warnings by auto generating shorthand interface me…

…thods
  • Loading branch information...
1 parent e543991 commit b253cc80416454d5dde67b32fc7d621d439720ff @casademora casademora committed Nov 15, 2011
View
35 Magical Record.xcodeproj/project.pbxproj
@@ -50,8 +50,8 @@
C753897413DB61CE002B2F57 /* GHUnitTestMain.m in Sources */ = {isa = PBXBuildFile; fileRef = C753897313DB61CE002B2F57 /* GHUnitTestMain.m */; };
C753897613DB6322002B2F57 /* GHUnit.framework in Copy GHUnit into App Bundle */ = {isa = PBXBuildFile; fileRef = C721C84113D0C6460097AB6F /* GHUnit.framework */; };
C75A4E7313D0D88D00790CEB /* NSManagedObject+MagicalDataImport.m in Sources */ = {isa = PBXBuildFile; fileRef = C75A4E7213D0D88D00790CEB /* NSManagedObject+MagicalDataImport.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
- C75C7D6A147220D400D0C2FE /* ProcessHeader.rb in Resources */ = {isa = PBXBuildFile; fileRef = C75C7D69147220D300D0C2FE /* ProcessHeader.rb */; };
- C75C7D6B147220D400D0C2FE /* ProcessHeader.rb in Resources */ = {isa = PBXBuildFile; fileRef = C75C7D69147220D300D0C2FE /* ProcessHeader.rb */; };
+ C75C7D6A147220D400D0C2FE /* generateShorthandFile.rb in Resources */ = {isa = PBXBuildFile; fileRef = C75C7D69147220D300D0C2FE /* generateShorthandFile.rb */; };
+ C75C7D6B147220D400D0C2FE /* generateShorthandFile.rb in Resources */ = {isa = PBXBuildFile; fileRef = C75C7D69147220D300D0C2FE /* generateShorthandFile.rb */; };
C763783213E10BEC0009A6CA /* GHUnitIOSTestMain.m in Sources */ = {isa = PBXBuildFile; fileRef = C763783113E10BEC0009A6CA /* GHUnitIOSTestMain.m */; };
C76AF7E513DBC08F00CE2E05 /* FixtureHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = C77E5FBA13D0D2AE00298F87 /* FixtureHelpers.m */; };
C76AF7E613DBC08F00CE2E05 /* MagicalRecordHelperTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C77E5FA713D0CBDE00298F87 /* MagicalRecordHelperTests.m */; };
@@ -250,7 +250,7 @@
C753897313DB61CE002B2F57 /* GHUnitTestMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHUnitTestMain.m; sourceTree = "<group>"; };
C75A4E7113D0D88D00790CEB /* NSManagedObject+MagicalDataImport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObject+MagicalDataImport.h"; sourceTree = "<group>"; };
C75A4E7213D0D88D00790CEB /* NSManagedObject+MagicalDataImport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObject+MagicalDataImport.m"; sourceTree = "<group>"; };
- C75C7D69147220D300D0C2FE /* ProcessHeader.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = ProcessHeader.rb; sourceTree = "<group>"; };
+ C75C7D69147220D300D0C2FE /* generateShorthandFile.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = generateShorthandFile.rb; sourceTree = "<group>"; };
C763783113E10BEC0009A6CA /* GHUnitIOSTestMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHUnitIOSTestMain.m; sourceTree = "<group>"; };
C76AF7F813DBE8D300CE2E05 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
C76AF7FA13DBEB5500CE2E05 /* ImportSingleRelatedEntityTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ImportSingleRelatedEntityTests.m; path = "Unit Tests/ImportSingleRelatedEntityTests.m"; sourceTree = "<group>"; };
@@ -288,6 +288,7 @@
C7913BAE13FB1E11007E09CC /* SingleEntityRelatedToMappedEntityWithNestedMappedAttributes.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = SingleEntityRelatedToMappedEntityWithNestedMappedAttributes.json; path = "Unit Tests/Fixtures/SingleEntityRelatedToMappedEntityWithNestedMappedAttributes.json"; sourceTree = "<group>"; };
C7B7379913FAE5D500EE4940 /* SingleEntityRelatedToManyMappedEntitiesUsingMappedPrimaryKey.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = SingleEntityRelatedToManyMappedEntitiesUsingMappedPrimaryKey.json; path = "Unit Tests/Fixtures/SingleEntityRelatedToManyMappedEntitiesUsingMappedPrimaryKey.json"; sourceTree = "<group>"; };
C7B7379D13FAE6D000EE4940 /* ImportSingleEntityRelatedToManyMappedEntitiesUsingMappedPrimaryKeyTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ImportSingleEntityRelatedToManyMappedEntitiesUsingMappedPrimaryKeyTests.m; path = "Unit Tests/ImportSingleEntityRelatedToManyMappedEntitiesUsingMappedPrimaryKeyTests.m"; sourceTree = "<group>"; };
+ C7B8733C1472DD260046776C /* MagicalRecordShorthand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MagicalRecordShorthand.h; sourceTree = "<group>"; };
C7BD885213DBF88F00274567 /* _AbstractRelatedEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _AbstractRelatedEntity.h; sourceTree = "<group>"; };
C7BD885313DBF88F00274567 /* _AbstractRelatedEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _AbstractRelatedEntity.m; sourceTree = "<group>"; };
C7BD885413DBF88F00274567 /* _ConcreteRelatedEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _ConcreteRelatedEntity.h; sourceTree = "<group>"; };
@@ -398,7 +399,7 @@
C721C7A013D0A3750097AB6F = {
isa = PBXGroup;
children = (
- C75C7D69147220D300D0C2FE /* ProcessHeader.rb */,
+ C75C7D69147220D300D0C2FE /* generateShorthandFile.rb */,
C721C85513D0C7030097AB6F /* Source */,
C77E5FA513D0CBA600298F87 /* Unit Tests */,
C721C7E413D0C3A00097AB6F /* Mac App Unit Tests */,
@@ -563,6 +564,7 @@
C721C86513D0C7030097AB6F /* CoreData+MagicalRecord.h */,
C721C86613D0C7030097AB6F /* MagicalRecordHelpers.h */,
C721C86713D0C7030097AB6F /* MagicalRecordHelpers.m */,
+ C7B8733C1472DD260046776C /* MagicalRecordShorthand.h */,
);
path = Source;
sourceTree = "<group>";
@@ -802,6 +804,7 @@
isa = PBXNativeTarget;
buildConfigurationList = C721C81C13D0C3CD0097AB6F /* Build configuration list for PBXNativeTarget "iOS App Unit Tests" */;
buildPhases = (
+ C7B8733A1472CFA20046776C /* Generate Shorthand Headers */,
C7BD887613DBF8FA00274567 /* Regenerate Core Data Entities */,
C721C7F913D0C3CD0097AB6F /* Sources */,
C7E37A7B14157BE600CE9BF5 /* CopyFiles */,
@@ -855,7 +858,7 @@
C76AF7ED13DBC09800CE2E05 /* SampleJSONDataForImport.json in Resources */,
C76AF7EE13DBC09B00CE2E05 /* SingleEntityWithNoRelationships.plist in Resources */,
C76AF82A13DBEE5A00CE2E05 /* SingleRelatedEntity.json in Resources */,
- C75C7D6A147220D400D0C2FE /* ProcessHeader.rb in Resources */,
+ C75C7D6A147220D400D0C2FE /* generateShorthandFile.rb in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -874,7 +877,7 @@
C78F8FD313FDC2B600549DD8 /* SingleEntityRelatedToMappedEntityWithSecondaryMappings.json in Resources */,
C7E736DF1402FE64005657C9 /* SingleEntityWithNoRelationships.json in Resources */,
C738127B141039900054EEF0 /* SingleEntityRelatedToManyMappedEntitiesUsingListOfPrimaryKeys.json in Resources */,
- C75C7D6B147220D400D0C2FE /* ProcessHeader.rb in Resources */,
+ C75C7D6B147220D400D0C2FE /* generateShorthandFile.rb in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -895,6 +898,20 @@
shellPath = /bin/sh;
shellScript = "cd \"Unit Tests/Fixtures/Mac\" && mogenerator -m TestModel.xcdatamodeld/TestModel.xcdatamodel -O TestEntities";
};
+ C7B8733A1472CFA20046776C /* Generate Shorthand Headers */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "Generate Shorthand Headers";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "$PROJECT_DIR/generateShorthandFile.rb $PROJECT_DIR/Source $PROJECT_DIR/Source/MagicalRecordShorthand.h";
+ };
C7BD887613DBF8FA00274567 /* Regenerate Core Data Entities */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -1193,6 +1210,7 @@
);
MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS = YES;
MOMC_NO_WARNINGS = YES;
+ OTHER_CFLAGS = "-DMR_SHORTHAND";
OTHER_LDFLAGS = (
"-all_load",
"-ObjC",
@@ -1241,7 +1259,10 @@
);
MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS = YES;
MOMC_NO_WARNINGS = YES;
- OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ OTHER_CFLAGS = (
+ "-DMR_SHORTHAND",
+ "-DNS_BLOCK_ASSERTIONS=1",
+ );
OTHER_LDFLAGS = (
"-all_load",
"-ObjC",
View
4 Source/CoreData+MagicalRecord.h
@@ -14,6 +14,10 @@
#import <CoreData/CoreData.h>
+#ifdef MR_SHORTHAND
+#import "MagicalRecordShorthand.h"
+#endif
+
#import "MagicalRecordHelpers.h"
#import "MRCoreDataAction.h"
View
146 Source/MagicalRecordShorthand.h
@@ -0,0 +1,146 @@
+#ifdef MR_SHORTHAND
+
+
+
+
+
+
+@interface NSManagedObject (NSManagedObject_DataImportShortHand)
+- (void) importValuesForKeysWithDictionary:(NSDictionary *)objectData;
+- (void) updateValuesForKeysWithDictionary:(NSDictionary *)objectData;
++ (id) importFromDictionary:(NSDictionary *)data;
++ (id) importFromDictionary:(NSDictionary *)data inContext:(NSManagedObjectContext *)context;
++ (NSArray *) importFromArray:(NSArray *)listOfObjectData;
++ (NSArray *) importFromArray:(NSArray *)listOfObjectData inContext:(NSManagedObjectContext *)context;
++ (id) updateFromDictionary:(NSDictionary *)objectData;
++ (id) updateFromDictionary:(NSDictionary *)objectData inContext:(NSManagedObjectContext *)context;
+@end
+@interface NSManagedObject (MagicalRecordShortHand)
++ (NSUInteger) defaultBatchSize;
++ (void) setDefaultBatchSize:(NSUInteger)newBatchSize;
++ (NSArray *) executeFetchRequest:(NSFetchRequest *)request;
++ (NSArray *) executeFetchRequest:(NSFetchRequest *)request inContext:(NSManagedObjectContext *)context;
++ (id) executeFetchRequestAndReturnFirstObject:(NSFetchRequest *)request;
++ (id) executeFetchRequestAndReturnFirstObject:(NSFetchRequest *)request inContext:(NSManagedObjectContext *)context;
++ (NSFetchRequest *) createFetchRequest;
++ (NSFetchRequest *) createFetchRequestInContext:(NSManagedObjectContext *)context;
++ (NSEntityDescription *) entityDescription;
++ (NSEntityDescription *) entityDescriptionInContext:(NSManagedObjectContext *)context;
++ (NSArray *) propertiesNamed:(NSArray *)properties;
++ (id) createEntity;
++ (id) createInContext:(NSManagedObjectContext *)context;
+- (BOOL) deleteEntity;
+- (BOOL) deleteInContext:(NSManagedObjectContext *)context;
++ (BOOL) deleteAllMatchingPredicate:(NSPredicate *)predicate;
++ (BOOL) deleteAllMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context;
++ (BOOL) truncateAll;
++ (BOOL) truncateAllInContext:(NSManagedObjectContext *)context;
++ (NSArray *) ascendingSortDescriptors:(NSArray *)attributesToSortBy;
++ (NSArray *) descendingSortDescriptors:(NSArray *)attributesToSortBy;
++ (NSNumber *) numberOfEntities;
++ (NSNumber *) numberOfEntitiesWithContext:(NSManagedObjectContext *)context;
++ (NSNumber *) numberOfEntitiesWithPredicate:(NSPredicate *)searchTerm;
++ (NSNumber *) numberOfEntitiesWithPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;
++ (NSUInteger) countOfEntities;
++ (NSUInteger) countOfEntitiesWithContext:(NSManagedObjectContext *)context;
++ (NSUInteger) countOfEntitiesWithPredicate:(NSPredicate *)searchFilter;
++ (NSUInteger) countOfEntitiesWithPredicate:(NSPredicate *)searchFilter inContext:(NSManagedObjectContext *)context;
++ (BOOL) hasAtLeastOneEntity;
++ (BOOL) hasAtLeastOneEntityInContext:(NSManagedObjectContext *)context;
++ (NSFetchRequest *) requestAll;
++ (NSFetchRequest *) requestAllInContext:(NSManagedObjectContext *)context;
++ (NSFetchRequest *) requestAllWithPredicate:(NSPredicate *)searchTerm;
++ (NSFetchRequest *) requestAllWithPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;
++ (NSFetchRequest *) requestAllWhere:(NSString *)property isEqualTo:(id)value;
++ (NSFetchRequest *) requestAllWhere:(NSString *)property isEqualTo:(id)value inContext:(NSManagedObjectContext *)context;
++ (NSFetchRequest *) requestFirstWithPredicate:(NSPredicate *)searchTerm;
++ (NSFetchRequest *) requestFirstWithPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;
++ (NSFetchRequest *) requestFirstByAttribute:(NSString *)attribute withValue:(id)searchValue;
++ (NSFetchRequest *) requestFirstByAttribute:(NSString *)attribute withValue:(id)searchValue inContext:(NSManagedObjectContext *)context;
++ (NSFetchRequest *) requestAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending;
++ (NSFetchRequest *) requestAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context;
++ (NSFetchRequest *) requestAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending withPredicate:(NSPredicate *)searchTerm;
++ (NSFetchRequest *) requestAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending withPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;
++ (NSArray *) findAll;
++ (NSArray *) findAllInContext:(NSManagedObjectContext *)context;
++ (NSArray *) findAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending;
++ (NSArray *) findAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context;
++ (NSArray *) findAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending withPredicate:(NSPredicate *)searchTerm;
++ (NSArray *) findAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending withPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;
++ (NSArray *) findAllWithPredicate:(NSPredicate *)searchTerm;
++ (NSArray *) findAllWithPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;
+- (id) objectWithMinValueFor:(NSString *)property;
+- (id) objectWithMinValueFor:(NSString *)property inContext:(NSManagedObjectContext *)context;
++ (id) findFirst;
++ (id) findFirstInContext:(NSManagedObjectContext *)context;
++ (id) findFirstWithPredicate:(NSPredicate *)searchTerm;
++ (id) findFirstWithPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;
++ (id) findFirstWithPredicate:(NSPredicate *)searchterm sortedBy:(NSString *)property ascending:(BOOL)ascending;
++ (id) findFirstWithPredicate:(NSPredicate *)searchterm sortedBy:(NSString *)property ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context;
++ (id) findFirstWithPredicate:(NSPredicate *)searchTerm andRetrieveAttributes:(NSArray *)attributes;
++ (id) findFirstWithPredicate:(NSPredicate *)searchTerm andRetrieveAttributes:(NSArray *)attributes inContext:(NSManagedObjectContext *)context;
++ (id) findFirstWithPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortBy ascending:(BOOL)ascending andRetrieveAttributes:(id)attributes, ...;
++ (id) findFirstWithPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortBy ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context andRetrieveAttributes:(id)attributes, ...;
++ (id) findFirstByAttribute:(NSString *)attribute withValue:(id)searchValue;
++ (id) findFirstByAttribute:(NSString *)attribute withValue:(id)searchValue inContext:(NSManagedObjectContext *)context;
++ (NSArray *) findByAttribute:(NSString *)attribute withValue:(id)searchValue;
++ (NSArray *) findByAttribute:(NSString *)attribute withValue:(id)searchValue inContext:(NSManagedObjectContext *)context;
++ (NSArray *) findByAttribute:(NSString *)attribute withValue:(id)searchValue andOrderBy:(NSString *)sortTerm ascending:(BOOL)ascending;
++ (NSArray *) findByAttribute:(NSString *)attribute withValue:(id)searchValue andOrderBy:(NSString *)sortTerm ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context;
+- (id) inContext:(NSManagedObjectContext *)otherContext;
+- (id) inThreadContext;
++ (void) performFetch:(NSFetchedResultsController *)controller;
++ (NSFetchedResultsController *) fetchAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending withPredicate:(NSPredicate *)searchTerm groupBy:(NSString *)groupingKeyPath delegate:(id)delegate;
++ (NSFetchedResultsController *) fetchAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending withPredicate:(NSPredicate *)searchTerm groupBy:(NSString *)groupingKeyPath delegate:(id)delegate inContext:(NSManagedObjectContext *)context;
++ (NSFetchedResultsController *) fetchRequest:(NSFetchRequest *)request groupedBy:(NSString *)group;
++ (NSFetchedResultsController *) fetchRequest:(NSFetchRequest *)request groupedBy:(NSString *)group inContext:(NSManagedObjectContext *)context;
++ (NSFetchedResultsController *) fetchRequestAllGroupedBy:(NSString *)group withPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortTerm ascending:(BOOL)ascending;
++ (NSFetchedResultsController *) fetchRequestAllGroupedBy:(NSString *)group withPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortTerm ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context;
++ (NSFetchedResultsController *) fetchRequestAllGroupedBy:(NSString *)group withPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortTerm ascending:(BOOL)ascending delegate:(id)delegate;
++ (NSFetchedResultsController *) fetchRequestAllGroupedBy:(NSString *)group withPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortTerm ascending:(BOOL)ascending delegate:(id)delegate inContext:(NSManagedObjectContext *)context;
+@end
+@interface NSManagedObjectContext (MagicalRecordShortHand)
+- (void) observeContext:(NSManagedObjectContext *)otherContext;
+- (void) stopObservingContext:(NSManagedObjectContext *)otherContext;
+- (void) observeContextOnMainThread:(NSManagedObjectContext *)otherContext;
+- (BOOL) save;
+- (BOOL) saveWithErrorHandler:(void (^)(NSError *))errorCallback;
+- (BOOL) saveOnMainThread;
+- (BOOL) saveOnBackgroundThread;
++ (void) resetDefaultContext;
++ (NSManagedObjectContext *)defaultContext;
++ (void) setDefaultContext:(NSManagedObjectContext *)moc;
++ (void) resetContextForCurrentThread;
++ (NSManagedObjectContext *) context;
++ (NSManagedObjectContext *) contextForCurrentThread;
++ (NSManagedObjectContext *) contextThatNotifiesDefaultContextOnMainThread;
++ (NSManagedObjectContext *) contextThatNotifiesDefaultContextOnMainThreadWithCoordinator:(NSPersistentStoreCoordinator *)coordinator;
++ (NSManagedObjectContext *) contextWithStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator;
+@end
+@interface NSManagedObjectModel (MagicalRecordShortHand)
++ (NSManagedObjectModel *) defaultManagedObjectModel;
++ (void) setDefaultManagedObjectModel:(NSManagedObjectModel *)newDefaultModel;
++ (NSManagedObjectModel *) newManagedObjectModel NS_RETURNS_RETAINED;
++ (NSManagedObjectModel *) newManagedObjectModelNamed:(NSString *)modelFileName NS_RETURNS_RETAINED;
++ (NSManagedObjectModel *) managedObjectModelNamed:(NSString *)modelFileName;
++ (NSManagedObjectModel *) newModelNamed:(NSString *) modelName inBundleNamed:(NSString *) bundleName NS_RETURNS_RETAINED;
++ (NSManagedObjectModel *) mergedObjectModelFromMainBundle;
+@end
+@interface NSPersistentStore (MagicalRecordShortHand)
++ (NSURL *) defaultLocalStoreUrl;
++ (NSPersistentStore *) defaultPersistentStore;
++ (void) setDefaultPersistentStore:(NSPersistentStore *) store;
++ (NSURL *) urlForStoreName:(NSString *)storeFileName;
+@end
+@interface NSPersistentStoreCoordinator (MagicalRecordShortHand)
++ (NSPersistentStoreCoordinator *) defaultStoreCoordinator;
++ (void) setDefaultStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator;
++ (NSPersistentStoreCoordinator *) coordinatorWithInMemoryStore;
++ (NSPersistentStoreCoordinator *) newPersistentStoreCoordinator NS_RETURNS_RETAINED;
++ (NSPersistentStoreCoordinator *) coordinatorWithSqliteStoreNamed:(NSString *)storeFileName;
++ (NSPersistentStoreCoordinator *) coordinatorWithAutoMigratingSqliteStoreNamed:(NSString *) storeFileName;
++ (NSPersistentStoreCoordinator *) coordinatorWithPersitentStore:(NSPersistentStore *)persistentStore;
+- (NSPersistentStore *) addInMemoryStore;
+@end
+#endif
+
View
67 ProcessHeader.rb → generateShorthandFile.rb 100644 → 100755
@@ -1,3 +1,4 @@
+#!/usr/local/Cellar/ruby/1.9.2-p290/bin/ruby
#
# ProcessHeader.rb
# Magical Record
@@ -21,13 +22,20 @@ def processHeader(headerFile)
lines = File.readlines(headerFile)
non_prefixed_methods = []
processed_methods_count = 0
+ objects_to_process = ["NSManagedObject", "NSManagedObjectContext", "NSManagedObjectModel", "NSPersistentStoreCoordinator", "NSPersistentStore"]
lines.each { |line|
processed_line = nil
if line.start_with?("@interface")
matches = category_match_expression.match(line)
- processed_line = "#{matches[:Interface]} #{matches[:ObjectName]} (#{matches[:Category]}ShortHand)"
+ if objects_to_process.include?(matches[:ObjectName])
+ processed_line = "#{matches[:Interface]} #{matches[:ObjectName]} (#{matches[:Category]}ShortHand)"
+ else
+ puts "Skipping #{headerFile}"
+ non_prefixed_methods = nil
+ return
+ end
end
if processed_line == nil
@@ -40,6 +48,7 @@ def processHeader(headerFile)
processed_line = "#{matches[:Start]}#{methodName}#{matches[:End]}"
else
+ puts "Skipping #{headerFile}"
non_prefixed_methods = nil
return
end
@@ -58,37 +67,67 @@ def processHeader(headerFile)
end
}
- non_prefixed_methods #unless processed_methods_count == 0
+ non_prefixed_methods
end
def processDirectory(path)
headers = File.join(path, "**", "*+*.h")
+ processedHeaders = []
+
Dir.glob(headers).each { |file|
-# puts "Processing #{file}"
+ puts "Processing #{file}"
processDirectory(file) if File.directory?(file)
if file.end_with?(".h")
- processedInterface = processHeader(file)
-
- puts processedInterface
+ processedHeaders << processHeader(file)
end
}
+ processedHeaders
end
-if ARGV[0]
- path = "#{Dir.pwd}/#{ARGV[0]}"
-
- if path.end_with?(".h")
- processedInterface = processHeader(path)
+def generateHeaders(startingPoint)
+
+ processedHeaders = []
+ if startingPoint
+ path = File.expand_path(startingPoint)
- puts processedInterface
+ if path.end_with?(".h")
+ processedHeaders << processHeader(path)
+ else
+ puts "Processing Headers in #{path}"
+ processedHeaders << processDirectory(path)
+ end
else
- processDirectory(path)
+ processedHeaders << processDirectory(startingPoint || Dir.getwd())
end
+
+ processedHeaders
+end
+
+puts "Input dir: #{File.expand_path(ARGV[0])}"
+
+output_file = ARGV[1]
+puts "Output file: #{File.expand_path(output_file)}"
+
+unless output_file
+ puts "Need an output file specified"
+ return
else
- processDirectory(ARGV[0] || Dir.getwd())
+ puts "Genrating shorthand headers"
end
+
+headers = generateHeaders(ARGV[0])
+
+File.open(output_file, "w") { |file|
+ file.write("#ifdef MR_SHORTHAND\n\n")
+ file.write(headers.join("\n"))
+ file.write("#endif\n\n")
+}
+
+
+
+
View
2 iOS App Unit Tests/iOS App Unit Tests-Prefix.pch
@@ -19,7 +19,7 @@
#define HC_SHORTHAND
#import <OCHamcrestIOS/OCHamcrestIOS.h>
- #define MR_SHORTHAND
+// #define MR_SHORTHAND
#import "CoreData+MagicalRecord.h"
#import "FixtureHelpers.h"
#endif

0 comments on commit b253cc8

Please sign in to comment.