--
You received this message because you are subscribed to the Google Groups "Realm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realm-cocoa...@googlegroups.com.
To post to this group, send email to realm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/realm-cocoa/0b197175-3d8a-4ce4-b719-1fc25bf5a636%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
- (NSArray *)rooms { return [self linkingObjectsOfClass:@"Room" forProperty:@"facility"];}
@implementation FacilityIdTransformer
+ (instancetype)valueTransformer { return [[self alloc] init];}
+ (BOOL)allowsReverseTransformation { return NO;}
- (id)transformedValue:(id)value { NSInteger facId = [value integerValue]; Facility *fac = [Facility objectInRealm:[RLMRealm defaultRealm] forPrimaryKey:[NSNumber numberWithInteger:facId]]; return fac;}
@end
@property Faciltiies facility;
@"facilitiyId": @"facility"
+ (NSValueTransformer *)facilityJSONTransformer {
return [FacilityTransformer valueTransformer];
}
+ (NSValueTransformer *)countryJSONTransformer {
return [CountryCodeTransformer valueTransformer];
}
@implementation CountryCodeTransformer
+ (instancetype)valueTransformer {
return [[self alloc] init];
}
+ (BOOL)allowsReverseTransformation {
return NO;
}
- (id)transformedValue:(id)value {
Country *country;
if (value) {
NSString *countryCode = value;
country = [Country objectsInRealm:[RLMRealm defaultRealm] where:@"code = %@", countryCode].firstObject;
}
return country;
}
@end