- Fix Exception in PNObject ReverseMapping method
This commit is contained in:
parent
566019c57f
commit
437a3e8e47
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "PNObject"
|
s.name = "PNObject"
|
||||||
s.version = "0.5.0"
|
s.version = "0.5.1"
|
||||||
s.summary = "PNObject is a simple replica of the more complex ParseObject"
|
s.summary = "PNObject is a simple replica of the more complex ParseObject"
|
||||||
|
|
||||||
# This description is used to generate tags and improve search results.
|
# This description is used to generate tags and improve search results.
|
||||||
|
|||||||
@ -222,14 +222,7 @@ NSString * const PNObjectMappingSelector = @"selector";
|
|||||||
|
|
||||||
@try {
|
@try {
|
||||||
value = [self valueForKey:propertyName];
|
value = [self valueForKey:propertyName];
|
||||||
}
|
|
||||||
@catch (NSException *exception) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
@finally {
|
|
||||||
|
|
||||||
//NSLog(@"PropertyName PropertyType Value: %@ - %@ - %@",propertyName,propertyType,value);
|
|
||||||
|
|
||||||
((void (^)())@{
|
((void (^)())@{
|
||||||
@"c" : ^{
|
@"c" : ^{
|
||||||
char val = [value charValue];
|
char val = [value charValue];
|
||||||
@ -261,7 +254,7 @@ NSString * const PNObjectMappingSelector = @"selector";
|
|||||||
},
|
},
|
||||||
@"NSURL" : ^{
|
@"NSURL" : ^{
|
||||||
NSURL *url = value;
|
NSURL *url = value;
|
||||||
|
|
||||||
if (![self isObjNull:url]) {
|
if (![self isObjNull:url]) {
|
||||||
[JSON setValue:[url absoluteString] forKey:propertyName];
|
[JSON setValue:[url absoluteString] forKey:propertyName];
|
||||||
}
|
}
|
||||||
@ -285,37 +278,37 @@ NSString * const PNObjectMappingSelector = @"selector";
|
|||||||
@"NSArray" : ^{
|
@"NSArray" : ^{
|
||||||
NSMutableArray *arr = [NSMutableArray array];
|
NSMutableArray *arr = [NSMutableArray array];
|
||||||
for(id object in value) {
|
for(id object in value) {
|
||||||
|
|
||||||
BOOL isPNObjectSubclass = [[object class] isSubclassOfClass:[PNObject class]];
|
BOOL isPNObjectSubclass = [[object class] isSubclassOfClass:[PNObject class]];
|
||||||
if(isPNObjectSubclass) {
|
if(isPNObjectSubclass) {
|
||||||
NSDictionary *objectDict = [(PNObject*) object reverseMapping];
|
NSDictionary *objectDict = [(PNObject*) object reverseMapping];
|
||||||
|
|
||||||
[arr addObject:objectDict];
|
[arr addObject:objectDict];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[JSON setValue:arr forKey:propertyName];
|
[JSON setValue:arr forKey:propertyName];
|
||||||
},
|
},
|
||||||
@"NSMutableArray" : ^{
|
@"NSMutableArray" : ^{
|
||||||
NSMutableArray *arr = [NSMutableArray array];
|
NSMutableArray *arr = [NSMutableArray array];
|
||||||
for(id object in value) {
|
for(id object in value) {
|
||||||
|
|
||||||
BOOL isPNObjectSubclass = [[object class] isSubclassOfClass:[PNObject class]];
|
BOOL isPNObjectSubclass = [[object class] isSubclassOfClass:[PNObject class]];
|
||||||
if(isPNObjectSubclass) {
|
if(isPNObjectSubclass) {
|
||||||
NSDictionary *objectDict = [(PNObject*) object reverseMapping];
|
NSDictionary *objectDict = [(PNObject*) object reverseMapping];
|
||||||
|
|
||||||
[arr addObject:objectDict];
|
[arr addObject:objectDict];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[JSON setValue:arr forKey:propertyName];
|
[JSON setValue:arr forKey:propertyName];
|
||||||
}
|
}
|
||||||
}[propertyType] ?: ^{
|
}[propertyType] ?: ^{
|
||||||
BOOL isPNObjectSubclass = [NSClassFromString(propertyType) isSubclassOfClass:[PNObject class]];
|
BOOL isPNObjectSubclass = [NSClassFromString(propertyType) isSubclassOfClass:[PNObject class]];
|
||||||
if(isPNObjectSubclass) {
|
if(isPNObjectSubclass) {
|
||||||
|
|
||||||
NSDictionary *objectDict = [(PNObject*)value reverseMapping];
|
NSDictionary *objectDict = [(PNObject*)value reverseMapping];
|
||||||
|
|
||||||
[JSON setValue:objectDict forKey:propertyName];
|
[JSON setValue:objectDict forKey:propertyName];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -323,6 +316,13 @@ NSString * const PNObjectMappingSelector = @"selector";
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
@catch (NSException *exception) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
@finally {
|
||||||
|
|
||||||
|
//NSLog(@"PropertyName PropertyType Value: %@ - %@ - %@",propertyName,propertyType,value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSON;
|
return JSON;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user