Skip to content

Instantly share code, notes, and snippets.

@nataliepo
Created May 2, 2014 22:25
Show Gist options
  • Save nataliepo/85b5e5e6c2e1ece8749f to your computer and use it in GitHub Desktop.
Save nataliepo/85b5e5e6c2e1ece8749f to your computer and use it in GitHub Desktop.
display_encouragement_logic
-(void)performFeedbackActionIfNeeded {
int index = 0;
BOOL found = NO;
int limit = [_logicUsedOnce count];
// Loop over the array of logic blocks.
// They'll draw the right thing as necessary.
while (!found && (index < limit)) {
BOOL (^checkCase)() = [_logicUsedOnce objectAtIndex:index];
if (checkCase()) {
[_logicUsedOnce removeObjectAtIndex:index];
found = YES;
}
index++;
}
// If you still haven't shown anything to the user,
// check the Repeated alerts.
index = 0;
limit = [_logicUsedRepeatedly count];
while (!found && (index < limit)) {
BOOL (^checkCase)() = [_logicUsedRepeatedly objectAtIndex:index];
if (checkCase()) {
found = YES;
}
index++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment