Skip to content

Instantly share code, notes, and snippets.

@jiro
Created October 18, 2012 12:03
Show Gist options
  • Save jiro/3911379 to your computer and use it in GitHub Desktop.
Save jiro/3911379 to your computer and use it in GitHub Desktop.
KVOの受信処理がメインスレッドで処理されるのを保証する ref: http://qiita.com/items/f7b10aac3ed515798d22
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (![NSThread isMainThread]) {
dispatch_async(dispatch_get_main_queue(), ^{
[self observeValueForKeyPath:keyPath ofObject:object change:change context:context];
});
return;
}
// KVOに関する処理
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment