Skip to content

Instantly share code, notes, and snippets.

@chrisallick
Created February 4, 2013 23:04
Show Gist options
  • Save chrisallick/4710587 to your computer and use it in GitHub Desktop.
Save chrisallick/4710587 to your computer and use it in GitHub Desktop.
Run a piece of code after a delay. I'm sure an Objective-C nerd loses it's wings every time i use this, but god damn is that useful as shiiiiit. Even worse, im iterating over subviews to destroy them.
double delayInSeconds = 1.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
//code to be executed on the main queue after delay
sendButton.frame = CGRectMake(0, self.view.frame.size.height-(191*.5), 640*.5, 191*.5);
CGRect frame = sendingLabel.frame;
frame.origin.y = -30 - frame.size.height;
[sendingLabel setFrame:frame];
for (id subview in self.view.subviews) {
if ([subview isMemberOfClass:[FillCircle class]]) {
[subview removeFromSuperview];
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment