Explorar el Código

Added test Realm file and classes to the sample app.

Tim Oliver hace 10 años
padre
commit
ac273fbfc9

+ 38 - 0
Example/UICatalog.xcodeproj/project.pbxproj

@@ -7,6 +7,9 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		22679D581C74188D002248FC /* Dog.m in Sources */ = {isa = PBXBuildFile; fileRef = 22679D571C74188D002248FC /* Dog.m */; };
+		22679D5C1C7418B6002248FC /* Owner.m in Sources */ = {isa = PBXBuildFile; fileRef = 22679D5B1C7418B6002248FC /* Owner.m */; };
+		22679D5D1C741A7A002248FC /* dogs.realm in Resources */ = {isa = PBXBuildFile; fileRef = 22679D551C741764002248FC /* dogs.realm */; };
 		3EC6487318FF8A5000024205 /* ReadMe.txt in Resources */ = {isa = PBXBuildFile; fileRef = 3EC6487218FF8A5000024205 /* ReadMe.txt */; };
 		5356823E18F3656900BAAD62 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5356823D18F3656900BAAD62 /* Foundation.framework */; };
 		5356824018F3656900BAAD62 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5356823F18F3656900BAAD62 /* CoreGraphics.framework */; };
@@ -47,7 +50,25 @@
 		94CB4D431A97183E0054A905 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 94CB4D421A97183E0054A905 /* libz.dylib */; };
 /* End PBXBuildFile section */
 
+/* Begin PBXCopyFilesBuildPhase section */
+		22161B631C74171A0009425F /* Embed Frameworks */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = "";
+			dstSubfolderSpec = 10;
+			files = (
+			);
+			name = "Embed Frameworks";
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXCopyFilesBuildPhase section */
+
 /* Begin PBXFileReference section */
+		22679D551C741764002248FC /* dogs.realm */ = {isa = PBXFileReference; lastKnownFileType = file; path = dogs.realm; sourceTree = "<group>"; };
+		22679D561C74188D002248FC /* Dog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Dog.h; sourceTree = "<group>"; };
+		22679D571C74188D002248FC /* Dog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Dog.m; sourceTree = "<group>"; };
+		22679D5A1C7418B6002248FC /* Owner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Owner.h; sourceTree = "<group>"; };
+		22679D5B1C7418B6002248FC /* Owner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Owner.m; sourceTree = "<group>"; };
 		3EC6487218FF8A5000024205 /* ReadMe.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadMe.txt; sourceTree = SOURCE_ROOT; };
 		5356823A18F3656900BAAD62 /* UICatalog.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UICatalog.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		5356823D18F3656900BAAD62 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -134,6 +155,18 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		22679D591C741891002248FC /* Realm */ = {
+			isa = PBXGroup;
+			children = (
+				22679D551C741764002248FC /* dogs.realm */,
+				22679D561C74188D002248FC /* Dog.h */,
+				22679D571C74188D002248FC /* Dog.m */,
+				22679D5A1C7418B6002248FC /* Owner.h */,
+				22679D5B1C7418B6002248FC /* Owner.m */,
+			);
+			name = Realm;
+			sourceTree = "<group>";
+		};
 		5356823118F3656900BAAD62 = {
 			isa = PBXGroup;
 			children = (
@@ -251,6 +284,7 @@
 		53874F9A18F36B6900510922 /* Application */ = {
 			isa = PBXGroup;
 			children = (
+				22679D591C741891002248FC /* Realm */,
 				5356824918F3656900BAAD62 /* main.m */,
 				5356827B18F3670300BAAD62 /* AAPLAppDelegate.h */,
 				5356827C18F3670300BAAD62 /* AAPLAppDelegate.m */,
@@ -281,6 +315,7 @@
 				5356823618F3656900BAAD62 /* Sources */,
 				5356823718F3656900BAAD62 /* Frameworks */,
 				5356823818F3656900BAAD62 /* Resources */,
+				22161B631C74171A0009425F /* Embed Frameworks */,
 			);
 			buildRules = (
 			);
@@ -323,6 +358,7 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				22679D5D1C741A7A002248FC /* dogs.realm in Resources */,
 				5356825418F3656900BAAD62 /* Main_iPad.storyboard in Resources */,
 				53874F9918F36B1800510922 /* Localizable.strings in Resources */,
 				5356825918F3656900BAAD62 /* Images.xcassets in Resources */,
@@ -338,6 +374,7 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				22679D5C1C7418B6002248FC /* Owner.m in Sources */,
 				535682AE18F3670300BAAD62 /* AAPLDatePickerController.m in Sources */,
 				535682AB18F3670300BAAD62 /* AAPLButtonViewController.m in Sources */,
 				535682B618F3670300BAAD62 /* AAPLSegmentedControlViewController.m in Sources */,
@@ -356,6 +393,7 @@
 				535682B918F3670300BAAD62 /* AAPLStepperViewController.m in Sources */,
 				535682AA18F3670300BAAD62 /* AAPLAppDelegate.m in Sources */,
 				535682B518F3670300BAAD62 /* AAPLProgressViewController.m in Sources */,
+				22679D581C74188D002248FC /* Dog.m in Sources */,
 				535682AD18F3670300BAAD62 /* AAPLCustomToolbarViewController.m in Sources */,
 				535682A818F3670300BAAD62 /* AAPLActivityIndicatorViewController.m in Sources */,
 				535682B818F3670300BAAD62 /* AAPLSplitViewControllerDelegate.m in Sources */,

+ 32 - 0
Example/UICatalog/AAPLAppDelegate.m

@@ -49,6 +49,10 @@
 
 #if DEBUG
 #import <FLEX/FLEX.h>
+#if __has_include(<Realm/Realm.h>)
+#import "Dog.h"
+#import "Owner.h"
+#endif
 #endif
 
 @interface AAPLAppDelegate () <NSURLConnectionDataDelegate, NSURLSessionDataDelegate>
@@ -66,6 +70,11 @@
     [[FLEXManager sharedManager] setNetworkDebuggingEnabled:YES];
     [self sendExampleNetworkRequests];
     self.repeatingLogExampleTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(sendExampleLogMessage) userInfo:nil repeats:YES];
+
+#if __has_include(<Realm/Realm.h>)
+    [self setUpRealm];
+#endif
+    
 #endif
     return YES;
 }
@@ -173,4 +182,27 @@
     [self.connections removeObject:connection];
 }
 
+#if __has_include(<Realm/Realm.h>)
+- (void)setUpRealm
+{
+    NSString *destinationPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
+    destinationPath = [destinationPath stringByAppendingPathComponent:@"dogs.realm"];
+    if ([[NSFileManager defaultManager] fileExistsAtPath:destinationPath isDirectory:nil]) {
+        return;
+    }
+    
+    NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"dogs" ofType:@"realm"];
+    if (resourcePath == nil) {
+        [RLMRealm realmWithPath:destinationPath];
+        return;
+    }
+    
+    NSError *error = nil;
+    [[NSFileManager defaultManager] copyItemAtPath:resourcePath toPath:destinationPath error:&error];
+    if (error == nil) {
+        [RLMRealm realmWithPath:destinationPath];
+    }
+}
+#endif
+
 @end

+ 22 - 0
Example/UICatalog/Dog.h

@@ -0,0 +1,22 @@
+//
+//  Dog.h
+//  UICatalog
+//
+//  Created by Tim Oliver on 17/02/2016.
+//  Copyright © 2016 Realm. All rights reserved.
+//
+
+#if __has_include(<Realm/Realm.h>)
+
+#import <Realm/Realm.h>
+#import "Owner.h"
+
+@interface Dog : RLMObject
+@property NSString *name;
+@property CGFloat height;
+@property NSDate *birthdate;
+@property BOOL vaccinated;
+@property Owner *owner;
+@end
+
+#endif

+ 16 - 0
Example/UICatalog/Dog.m

@@ -0,0 +1,16 @@
+//
+//  Dog.m
+//  UICatalog
+//
+//  Created by Tim Oliver on 17/02/2016.
+//  Copyright © 2016 Realm. All rights reserved.
+//
+
+#import "Dog.h"
+
+#if __has_include(<Realm/Realm.h>)
+
+@implementation Dog
+@end
+
+#endif

+ 17 - 0
Example/UICatalog/Owner.h

@@ -0,0 +1,17 @@
+//
+//  Owner.h
+//  UICatalog
+//
+//  Created by Tim Oliver on 17/02/2016.
+//  Copyright © 2016 Realm. All rights reserved.
+//
+
+#if __has_include(<Realm/Realm.h>)
+
+#import <Realm/Realm.h>
+
+@interface Owner : RLMObject
+@property NSString *name;
+@end
+
+#endif

+ 16 - 0
Example/UICatalog/Owner.m

@@ -0,0 +1,16 @@
+//
+//  Owner.m
+//  UICatalog
+//
+//  Created by Tim Oliver on 17/02/2016.
+//  Copyright © 2016 Realm. All rights reserved.
+//
+
+#import "Owner.h"
+
+#if __has_include(<Realm/Realm.h>)
+
+@implementation Owner
+@end
+
+#endif

BIN
Example/UICatalog/dogs.realm


+ 4 - 0
FLEX.xcodeproj/project.pbxproj

@@ -8,6 +8,7 @@
 
 /* Begin PBXBuildFile section */
 		04F1CA191C137CF1000A52B0 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 04F1CA181C137CF1000A52B0 /* LICENSE */; };
+		222C88221C7339DC007CA15F /* FLEXRealmDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = 222C88211C7339DC007CA15F /* FLEXRealmDefines.h */; };
 		224D49A81C673AB5000EAB86 /* FLEXRealmDatabaseManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 224D49A41C673AB5000EAB86 /* FLEXRealmDatabaseManager.h */; };
 		224D49A91C673AB5000EAB86 /* FLEXRealmDatabaseManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 224D49A51C673AB5000EAB86 /* FLEXRealmDatabaseManager.m */; };
 		224D49AA1C673AB5000EAB86 /* FLEXSQLiteDatabaseManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 224D49A61C673AB5000EAB86 /* FLEXSQLiteDatabaseManager.h */; };
@@ -165,6 +166,7 @@
 
 /* Begin PBXFileReference section */
 		04F1CA181C137CF1000A52B0 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
+		222C88211C7339DC007CA15F /* FLEXRealmDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXRealmDefines.h; sourceTree = "<group>"; };
 		224D49A41C673AB5000EAB86 /* FLEXRealmDatabaseManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXRealmDatabaseManager.h; sourceTree = "<group>"; };
 		224D49A51C673AB5000EAB86 /* FLEXRealmDatabaseManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXRealmDatabaseManager.m; sourceTree = "<group>"; };
 		224D49A61C673AB5000EAB86 /* FLEXSQLiteDatabaseManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXSQLiteDatabaseManager.h; sourceTree = "<group>"; };
@@ -595,6 +597,7 @@
 		779B1EBF1C0C4D7C001F5E49 /* DatabaseBrowser */ = {
 			isa = PBXGroup;
 			children = (
+				222C88211C7339DC007CA15F /* FLEXRealmDefines.h */,
 				779B1EC01C0C4D7C001F5E49 /* FLEXDatabaseManager.h */,
 				224D49A41C673AB5000EAB86 /* FLEXRealmDatabaseManager.h */,
 				224D49A51C673AB5000EAB86 /* FLEXRealmDatabaseManager.m */,
@@ -650,6 +653,7 @@
 				3A4C95381B5B21410088C3F2 /* FLEXNetworkRecorder.h in Headers */,
 				3A4C94251B5B20570088C3F2 /* FLEX.h in Headers */,
 				3A4C95051B5B21410088C3F2 /* FLEXArgumentInputViewFactory.h in Headers */,
+				222C88221C7339DC007CA15F /* FLEXRealmDefines.h in Headers */,
 				3A4C951E1B5B21410088C3F2 /* FLEXClassesTableViewController.h in Headers */,
 				779B1ED21C0C4D7C001F5E49 /* FLEXTableColumnHeader.h in Headers */,
 				3A4C94FD1B5B21410088C3F2 /* FLEXArgumentInputStructView.h in Headers */,