Skip to content

Commit

Permalink
Fixes #1560 - Type-safety added to two places to prevent crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
astralbodies committed Apr 11, 2014
1 parent f03bc9b commit ad57811
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions WordPress/Classes/Note.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ + (void)mergeNewNotes:(NSArray *)notesData {

WPAccount *account = (WPAccount *)[context objectWithID:[WPAccount defaultWordPressComAccount].objectID];
[notesData enumerateObjectsUsingBlock:^(NSDictionary *noteData, NSUInteger idx, BOOL *stop) {
NSNumber *noteID = [noteData objectForKey:@"id"];
NSString *noteID = [noteData stringForKey:@"id"];
NSArray *results = [existingNotes filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"noteID == %@", noteID]];

Note *note;
if ([results count] != 0) {
note = results[0];
} else {
note = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass(self) inManagedObjectContext:context];
note.noteID = [noteData objectForKey:@"id"];
note.noteID = [noteData stringForKey:@"id"];
note.account = account;
}
[note syncAttributes:noteData];
Expand Down
4 changes: 2 additions & 2 deletions WordPress/Classes/ReaderComment.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ __block void(__unsafe_unretained ^updateDepth)(NSArray *, NSNumber *) = ^void (N
+ (void)createOrUpdateWithDictionary:(NSDictionary *)dict forPost:(ReaderPost *)post withContext:(NSManagedObjectContext *)context {

NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"ReaderComment"];
request.predicate = [NSPredicate predicateWithFormat:@"(commentID = %@) AND (post.endpoint = %@)", [dict objectForKey:@"ID"], post.endpoint];
request.predicate = [NSPredicate predicateWithFormat:@"(commentID = %@) AND (post.endpoint = %@)", [dict numberForKey:@"ID"], post.endpoint];
request.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"dateCreated" ascending:YES]];
request.fetchLimit = 1;

Expand All @@ -156,7 +156,7 @@ + (void)createOrUpdateWithDictionary:(NSDictionary *)dict forPost:(ReaderPost *)
} else {
comment = (ReaderComment *)[NSEntityDescription insertNewObjectForEntityForName:@"ReaderComment"
inManagedObjectContext:context];
comment.commentID = [dict objectForKey:@"ID"];
comment.commentID = [dict numberForKey:@"ID"];
comment.post = post;
}

Expand Down

0 comments on commit ad57811

Please sign in to comment.