Created
February 18, 2009 22:33
-
-
Save vickeryj/66593 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
@implementation MyAppDelegate | |
static NSOperationQueue *sharedOperationQueue = nil; | |
- (void)applicationDidFinishLaunching:(UIApplication *)application { | |
//setup the operation queue | |
sharedOperationQueue = [[NSOperationQueue alloc] init]; | |
//limit the number of concurrent operations to 1, as performance suffers on the iPhone otherwise | |
[sharedOperationQueue setMaxConcurrentOperationCount:1]; | |
//Configure ObjectiveResource | |
[ObjectiveResourceConfig setSite:@"http://localhost:3000/"]; | |
// use json | |
[ObjectiveResourceConfig setResponseType:JSONResponse]; | |
// Configure and show the window | |
[window addSubview:[navigationController view]]; | |
[window makeKeyAndVisible]; | |
} | |
// put job in operation queue and run it when able | |
+ (void) runJob:(SEL)selector onTarget:(id)target withArgument:(id)argument { | |
NSInvocationOperation *operation = [[[NSInvocationOperation alloc] initWithTarget:target | |
selector:selector | |
object:argument] autorelease]; | |
[sharedOperationQueue addOperation:operation]; | |
} | |
@end | |
@implementation MyViewController | |
- (void) loadPeople { | |
self.people = [Person findAllRemote]; | |
[tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO]; | |
} | |
-(IBAction) refreshButtonWasPressed { | |
//when the refresh button is pressed, call loadPeople as a new operation | |
[MyAppDelegate runJob:@selector(loadPeople) onTarget:self withArgument:nil]; | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment