Created
April 1, 2014 14:01
-
-
Save funkyboy/9914571 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)createNewPost:(id)sender { | |
| if (!_posts) { | |
| _posts = [[NSMutableArray alloc] init]; | |
| } | |
| SMPost *p = [[SMPost alloc] init]; | |
| p.postTitle = [NSString stringWithFormat:@"No title %i", _posts.count ]; | |
| p.postBody = @"No body"; | |
| [p saveObjectWithCompletion:^(SMPost *post, NSError *error) { | |
| if (error == nil) { | |
| NSLog(@"created post on server %@", post); | |
| [_posts insertObject:post atIndex:0]; | |
| NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 | |
| inSection:0]; | |
| [self.tableView insertRowsAtIndexPaths:@[indexPath] | |
| withRowAnimation:UITableViewRowAnimationAutomatic]; | |
| } else { | |
| NSLog(@"error in saving %@", error); | |
| } | |
| }]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment