Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 2.60 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Use threading to wait for another class's method to execute, or is there a simpler way?
  2. [facebook requestWithMethodName:@"fql.query" andParams:dictionary andHttpMethod:@"GET" andDelegate:self];
  3.        
  4. - (void)requestLoading:(FBRequest *)request {
  5.     NSLog(@"Loading...");
  6. }
  7.  
  8. - (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
  9.     NSLog(@"Response received");
  10. }
  11.  
  12. - (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
  13.     NSLog(@"Request failed");
  14. }
  15.  
  16. - (void)request:(FBRequest *)request didLoadRawResponse:(NSData *)data {
  17.     NSLog(@"Request did load raw response");
  18. }
  19.        
  20. - (IBAction)friendsButtonPressed:(id)sender {
  21.     int selectionTag = [sender tag];
  22.  
  23.     //Get access to the instance of the wrapper in the app delegate (since it needs to remain refereced after app exits to log in and returns
  24.     MiniBfAppDelegate *appDelegate = (MiniBfAppDelegate *)[[UIApplication sharedApplication] delegate];
  25.     [appDelegate.facebookWrapper loadListDataFor:selectionTag];
  26.  
  27.     //Initialise the friends view controller
  28.     FriendsViewController *friendsViewController = [[FriendsViewController alloc] init];
  29.  
  30.     //NEED TO WAIT UNTIL LISTDATA IS RETURNED?
  31.  
  32.     //Give the friends view controller the list data
  33.     friendsViewController.listData = appDelegate.facebookWrapper.friendsList;
  34.  
  35.     //Push the friends view controller
  36.     friendsViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
  37.     [self.navigationController pushViewController:friendsViewController animated:YES];
  38.     [friendsViewController release];
  39. }
  40.        
  41. [[NSNotificationCenter defaultCenter] postNotificationName:@"myNotificationName"
  42.                                                         object:self
  43.                                                       userInfo:[NSDictionary dictionaryWithObject:XXXX forKey:@"someObject"]];
  44.        
  45. [[NSNotificationCenter defaultCenter] addObserver: self
  46.                                              selector: @selector(yourMethodHere:)
  47.                                                  name: @"myNotificationName"
  48.                                                object: nil];
  49.        
  50. - (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
  51.     NSLog(@"Response received");
  52.  
  53.     //Give the friends view controller the list data
  54.     friendsViewController.listData = appDelegate.facebookWrapper.friendsList;
  55.  
  56.     //Push the friends view controller
  57.     friendsViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
  58.     [self.navigationController pushViewController:friendsViewController animated:YES];
  59.     [friendsViewController release];
  60. }