Created
July 12, 2009 20:46
-
-
Save farcaller/145795 to your computer and use it in GitHub Desktop.
This file contains 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
- (void)onCatalog | |
{ | |
RSSCatalogController *c = [[RSSCatalogController alloc] initWithNibName:@"RSSCatalogController" bundle:nil]; | |
c.title = @"Catalog"; | |
#ifdef USE_BLOCKS | |
UIActivityIndicatorView *scrollerView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] autorelease]; | |
[scrollerView startAnimating]; | |
UIBarButtonItem *scrollerItem = [[[UIBarButtonItem alloc] initWithCustomView:scrollerView] autorelease]; | |
UIBarButtonItem *oldItem = [self.navigationItem.rightBarButtonItem retain]; | |
[self.navigationItem setRightBarButtonItem:scrollerItem animated:YES]; | |
NSOperationQueue *q = [[NSOperationQueue alloc] init]; | |
[q pl_addOperationWithBlock:^{ | |
// форкнули выполнение в поток | |
[c updateCategories]; // <--- медленная операция | |
[[NSThread mainThread] pl_performBlock: ^{ | |
// вернулись в основной поток | |
[self.navigationItem setRightBarButtonItem:[oldItem autorelease] animated:YES]; | |
[self.navigationController pushViewController:c animated:YES]; | |
[c release]; | |
[q autorelease]; | |
}]; | |
}]; | |
#else | |
[c updateCategories]; | |
[self.navigationController pushViewController:c animated:YES]; | |
[c release]; | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment