From 63ee24310eb4058a8200d542efcb42e45602e9a6 Mon Sep 17 00:00:00 2001 From: alexander_zhigulich Date: Sat, 10 Jan 2015 14:28:41 +0300 Subject: [PATCH 1/4] Fork submodule Parse-NSCoding and fix PFFile decoding. --- PFFile+NSCoding.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/PFFile+NSCoding.m b/PFFile+NSCoding.m index 5f7422d..16dd401 100644 --- a/PFFile+NSCoding.m +++ b/PFFile+NSCoding.m @@ -30,9 +30,15 @@ - (id)initWithCoder:(NSCoder*)aDecoder NSString* url = [aDecoder decodeObjectForKey:kPFFileURL]; NSData* data = [aDecoder decodeObjectForKey:kPFFileData]; - self = [PFFile fileWithName:name data:data]; + if (data) { + self = [PFFile fileWithName:name data:data]; + } else { + self = [PFFile new]; + [self setValue:name forKey:kPFFileName]; + [self setValue:url forKey:kPFFileURL]; + } if (self) { - [self setValue:url forKey:@"_url"]; + [self setValue:url forKey:kPFFileURL]; } return self; } From d24a01ad4c13ed2eba504e1bc6560738bd7a93f9 Mon Sep 17 00:00:00 2001 From: alexander_zhigulich Date: Tue, 24 Mar 2015 19:24:30 +0300 Subject: [PATCH 2/4] Due to recent changes in Parse SDK PFFile cache will not work. --- PFFile+NSCoding.m | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/PFFile+NSCoding.m b/PFFile+NSCoding.m index 16dd401..0973a33 100644 --- a/PFFile+NSCoding.m +++ b/PFFile+NSCoding.m @@ -17,30 +17,24 @@ @implementation PFFile (NSCoding) - (void)encodeWithCoder:(NSCoder*)encoder { - [encoder encodeObject:self.name forKey:kPFFileName]; + [encoder encodeObject:self.name forKey:kPFFileName]; [encoder encodeObject:self.url forKey:kPFFileURL]; - if (self.isDataAvailable) { - [encoder encodeObject:[self getData] forKey:kPFFileData]; - } + if (self.isDataAvailable) { + [encoder encodeObject:[self getData] forKey:kPFFileData]; + } } - (id)initWithCoder:(NSCoder*)aDecoder { - NSString* name = [aDecoder decodeObjectForKey:kPFFileName]; + NSString* name = [aDecoder decodeObjectForKey:kPFFileName]; NSString* url = [aDecoder decodeObjectForKey:kPFFileURL]; - NSData* data = [aDecoder decodeObjectForKey:kPFFileData]; - - if (data) { - self = [PFFile fileWithName:name data:data]; - } else { - self = [PFFile new]; - [self setValue:name forKey:kPFFileName]; - [self setValue:url forKey:kPFFileURL]; + NSData* data = [aDecoder decodeObjectForKey:kPFFileData]; + + self = [PFFile fileWithName:name data:data]; + if (self) { + [self setValue:url forKey:@"_url"]; } - if (self) { - [self setValue:url forKey:kPFFileURL]; - } - return self; + return self; } @end From 5b8873b395cdde39edf054334fb21137dbf9b91e Mon Sep 17 00:00:00 2001 From: alexander_zhigulich Date: Tue, 24 Mar 2015 19:25:00 +0300 Subject: [PATCH 3/4] + COPY properties. --- NSObject+Properties.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NSObject+Properties.m b/NSObject+Properties.m index 851c8ac..3c3238d 100644 --- a/NSObject+Properties.m +++ b/NSObject+Properties.m @@ -22,7 +22,7 @@ - (NSDictionary *)dynamicProperties { NSDictionary* properties = [self properties]; for (NSString* key in properties) { NSArray* attributes = properties[key][@"attributes"]; - if ([attributes containsObject:@"D"]) { + if ([attributes containsObject:@"D"] && ![attributes containsObject:@"C"]) { output[key] = properties[key]; } } From 0c9cae317cb079ac1a32ae62b50bdad5912c963e Mon Sep 17 00:00:00 2001 From: alexander_zhigulich Date: Thu, 26 Mar 2015 21:02:00 +0300 Subject: [PATCH 4/4] Fix cache for PFUser and PFFile (try to ignore it if data not available). --- PFFile+NSCoding.m | 11 +++++++---- PFObject+NSCoding.m | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/PFFile+NSCoding.m b/PFFile+NSCoding.m index 0973a33..bad29ea 100644 --- a/PFFile+NSCoding.m +++ b/PFFile+NSCoding.m @@ -30,11 +30,14 @@ - (id)initWithCoder:(NSCoder*)aDecoder NSString* url = [aDecoder decodeObjectForKey:kPFFileURL]; NSData* data = [aDecoder decodeObjectForKey:kPFFileData]; - self = [PFFile fileWithName:name data:data]; - if (self) { - [self setValue:url forKey:@"_url"]; + if (data) { + self = [PFFile fileWithName:name data:data]; + if (self) { + [self setValue:url forKey:@"_url"]; + } + return self; } - return self; + return nil; } @end diff --git a/PFObject+NSCoding.m b/PFObject+NSCoding.m index 835f463..51aa492 100644 --- a/PFObject+NSCoding.m +++ b/PFObject+NSCoding.m @@ -71,7 +71,9 @@ - (id)initWithCoder:(NSCoder*)aDecoder //Deserialize all non-nil Parse properties for (NSString* key in allKeys) { id obj = [aDecoder decodeObjectForKey:key]; - self[key] = obj; + if (obj) { + self[key] = obj; + } } //Deserialize all nil Parse properties with NSNull