Skip to content

Commit

Permalink
Merge pull request #201 from jtamboli/systemtags-sync-fix
Browse files Browse the repository at this point in the history
Handle nil values for Simplenote-synced content, tags, systemTags
  • Loading branch information
elasticthreads committed Aug 2, 2014
2 parents 9d97478 + 10e410d commit ea607c4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions SimplenoteEntryCollector.m
Expand Up @@ -159,6 +159,15 @@ - (NSDictionary*)preparedDictionaryWithFetcher:(SyncResponseFetcher*)fetcher rec

NSMutableDictionary *entry = [NSMutableDictionary dictionaryWithCapacity:12];
NSNumber *deleted = [NSNumber numberWithInt:[[rawObject objectForKey:@"deleted"] intValue]];
NSArray *systemTags = [rawObject objectForKey:@"systemTags"];
if (!systemTags)
systemTags = [NSArray array];
NSArray *tags = [rawObject objectForKey:@"tags"];
if (!tags)
tags = [NSArray array];
NSString *content = [rawObject objectForKey:@"content"];
if (!content)
content = [NSString string];
[entry setObject:key forKey:@"key"];
[entry setObject:[NSNumber numberWithInt:version] forKey:@"version"];
[entry setObject:deleted forKey:@"deleted"];
Expand All @@ -171,10 +180,10 @@ - (NSDictionary*)preparedDictionaryWithFetcher:(SyncResponseFetcher*)fetcher rec
if ([rawObject objectForKey:@"publishkey"]) {
[entry setObject:[rawObject objectForKey:@"publishURL"] forKey:@"publishkey"];
}
[entry setObject:[rawObject objectForKey:@"systemTags"] forKey:@"systemtags"];
[entry setObject:[rawObject objectForKey:@"tags"] forKey:@"tags"];
[entry setObject:systemTags forKey:@"systemtags"];
[entry setObject:tags forKey:@"tags"];
if ([[fetcher representedObject] conformsToProtocol:@protocol(SynchronizedNote)]) [entry setObject:[fetcher representedObject] forKey:@"NoteObject"];
[entry setObject:[rawObject objectForKey:@"content"] forKey:@"content"];
[entry setObject:content forKey:@"content"];

//NSLog(@"fetched entry %@" , entry);

Expand Down

0 comments on commit ea607c4

Please sign in to comment.