File tree Expand file tree Collapse file tree 4 files changed +46
-4
lines changed
Expand file tree Collapse file tree 4 files changed +46
-4
lines changed Original file line number Diff line number Diff line change 11platform :ios , '6.0'
22
3- pod 'AFNetworking' , '~> 2.3'
3+ pod 'AFNetworking'
44pod 'Realm+JSON' , :path => '../'
Original file line number Diff line number Diff line change 11Pod ::Spec . new do |s |
22 s . name = 'Realm+JSON'
3- s . version = '0.1.2 '
3+ s . version = '0.1.3 '
44 s . ios . deployment_target = '6.0'
55 s . license = { :type => 'MIT' , :file => 'LICENSE' }
66 s . summary = 'A concise Mantle-like way of working with Realm and JSON.'
@@ -15,8 +15,8 @@ Pod::Spec.new do |s|
1515 s . source_files = 'Realm+JSON/*.{h,m}'
1616 s . public_header_files = 'Realm+JSON/*.h'
1717
18- s . dependency 'Realm' , '0.82 .0'
18+ s . dependency 'Realm' , '0.83 .0'
1919 s . xcconfig = {
20- 'FRAMEWORK_SEARCH_PATHS' => '$(PODS_ROOT)/Realm/realm-cocoapods-0.82 .0/ios'
20+ 'FRAMEWORK_SEARCH_PATHS' => '$(PODS_ROOT)/Realm/realm-cocoapods-0.83 .0/ios'
2121 }
2222end
Original file line number Diff line number Diff line change 1818- (instancetype )initWithJSONDictionary : (NSDictionary *)dictionary ;
1919- (NSDictionary *)JSONDictionary ;
2020
21+ - (void )performInTransaction : (void (^)())transaction ;
22+ - (void )removeFromRealm ;
23+
2124@end
25+
26+ @interface RLMArray (SWAdditions)
27+
28+ - (NSArray *)NSArray ;
29+ - (NSArray *)JSONArray ;
30+
31+ @end
Original file line number Diff line number Diff line change @@ -72,6 +72,18 @@ - (NSDictionary *)JSONDictionary {
7272 return [self mc_createJSONDictionary ];
7373}
7474
75+ - (void )performInTransaction : (void (^)())transaction {
76+ NSAssert (transaction != nil , @" No transaction block provided" );
77+ [self .realm transactionWithBlock: transaction];
78+ }
79+
80+ - (void )removeFromRealm {
81+ [self performInTransaction: ^{
82+ [self .realm deleteObject: self ];
83+ }];
84+ }
85+
86+
7587#pragma mark - Private
7688
7789+ (instancetype )mc_createFromJSONDictionary : (NSDictionary *)dictionary {
@@ -397,3 +409,23 @@ - (NSString *)camelToSnakeCase {
397409}
398410
399411@end
412+
413+ @implementation RLMArray (SWAdditions)
414+
415+ - (NSArray *)NSArray {
416+ NSMutableArray *array = [NSMutableArray arrayWithCapacity: self .count];
417+ for (id object in self) {
418+ [array addObject: object];
419+ }
420+ return [array copy ];
421+ }
422+
423+ - (NSArray *)JSONArray {
424+ NSMutableArray *array = [NSMutableArray array ];
425+ for (RLMObject *object in self) {
426+ [array addObject: [object JSONDictionary ]];
427+ }
428+ return [array copy ];
429+ }
430+
431+ @end
You can’t perform that action at this time.
0 commit comments