Created
February 12, 2014 20:07
-
-
Save nebiros/8963499 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
| // An implementation. | |
| - (void)viewWillDisappear:(BOOL)animated | |
| { | |
| [super viewWillDisappear:animated]; | |
| // if (!self.isThingsSaved) { | |
| // [self saveThings]; | |
| // } | |
| [self saveThings]; | |
| } | |
| - (void)saveThings | |
| { | |
| __weak typeof(self) weakSelf = self; | |
| [thing saveRow:@{kTHTParseKeyPersonRecordId: @(self.person.recordID), | |
| kTHTParseKeyOriginalImage: originalImage ?: [NSNull null], | |
| kTHTParseKeyOriginalThumbnail: originalThumbnail ?: [NSNull null], | |
| kTHTParseKeyThings: self.things} | |
| usingBlock:^(BOOL succeeded, PFObject *aThing, NSError *error) { | |
| __strong typeof(weakSelf) strongSelf = weakSelf; | |
| // TODO: handle errors properly (jfas). | |
| if (error) { | |
| NSLog(@"[ERROR] - %s: %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:@"\n%@\n%@", [error localizedDescription], error.userInfo]); | |
| return; | |
| } | |
| if (succeeded) { | |
| // strongSelf.thingsSaved = YES; | |
| if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(thingAddedSuccessfully:)]) { | |
| [strongSelf.delegate thingAddedSuccessfully:(THTThing *) aThing]; | |
| } | |
| } | |
| }]; | |
| } | |
| // strongSelf is nil after viewWillDisappear is executed and the block is call, why?. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment