The call to fetchRemindersMatchingPredicate:completion:
is asynchronous. This means that your if
statement after this call is actually being done long before the call to fetchRemindersMatchingPredicate:completion:
is complete.
You can't have a useful return value in a method that does asynchronous processing. You need to change your checkForReminderWithTitle:saveChanges:
method to return void
and instead have it pass a completion block that will be called when the call to fetchRemindersMatchingPredicate:completion:
is done.
BTW - why is reminderExists
an NSNumber
pointer and not just a BOOL
?