Skip to content

Commit fbd3b83

Browse files
committed
Merge branch 'release/0.1.3'
2 parents a537412 + ba6727e commit fbd3b83

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

Demo/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
platform :ios, '6.0'
22

3-
pod 'AFNetworking', '~> 2.3'
3+
pod 'AFNetworking'
44
pod 'Realm+JSON', :path => '../'

Realm+JSON.podspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::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
}
2222
end

Realm+JSON/RLMObject+JSON.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,14 @@
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

Realm+JSON/RLMObject+JSON.m

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)