From 0e311289c55e9a78a015a8cb95f5db6ef440c2b4 Mon Sep 17 00:00:00 2001 From: pavankris Date: Sat, 25 Oct 2014 22:36:09 -0400 Subject: [PATCH] Fixes that were crashing because of data unavailable in PFFile and also ismemberofclass was return false because of which data was not constructed correctly --- PFFile+NSCoding.m | 10 ++++++++-- PFObject+NSCoding.m | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/PFFile+NSCoding.m b/PFFile+NSCoding.m index 5f7422d..20f78f9 100644 --- a/PFFile+NSCoding.m +++ b/PFFile+NSCoding.m @@ -29,8 +29,14 @@ - (id)initWithCoder:(NSCoder*)aDecoder NSString* name = [aDecoder decodeObjectForKey:kPFFileName]; NSString* url = [aDecoder decodeObjectForKey:kPFFileURL]; NSData* data = [aDecoder decodeObjectForKey:kPFFileData]; - - self = [PFFile fileWithName:name data:data]; + if (!data) { + self = [[PFFile alloc]init]; + [self setValue:name forKey:kPFFileName]; + } + else + { + self = [PFFile fileWithName:name data:data]; + } if (self) { [self setValue:url forKey:@"_url"]; } diff --git a/PFObject+NSCoding.m b/PFObject+NSCoding.m index 835f463..b4a9abe 100644 --- a/PFObject+NSCoding.m +++ b/PFObject+NSCoding.m @@ -53,7 +53,7 @@ - (id)initWithCoder:(NSCoder*)aDecoder NSArray* allKeys = [aDecoder decodeObjectForKey:kPFObjectAllKeys]; BOOL isDataAvailable = [aDecoder decodeBoolForKey:kPFObjectIsDataAvailableKey]; - if ([self isMemberOfClass:[PFObject class]]) { + if ([self isKindOfClass:[PFObject class]]) { //If this is a PFObject, recreate the object using the Parse class name and objectId self = [PFObject objectWithoutDataWithClassName:parseClassName objectId:objectId]; }