Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. @property (weak, nonatomic) IBOutlet UIPickerView *myPickerView;
  2. @property (strong, readwrite, nonatomic) NSMutableArray *userAccounts;
  3.  
  4.  
  5. -(void)authenticateUser
  6. {
  7. [self populateDataSourceWithResultBlock:^(NSArray *accounts, NSError *error)
  8. {
  9. [self.twitterAccountPickerView reloadAllComponents];
  10. }];
  11. }
  12.  
  13. - (void)populateDataSourceWithResultBlock:(void (^)(NSArray *accounts, NSError *error))resultBlock
  14. {
  15. self.userAccounts = [[NSMutableArray alloc] initWithObjects:@"one", @"two",nil];
  16.  
  17. dispatch_sync(dispatch_get_main_queue(), ^{
  18. resultBlock(self.userAccounts, error);
  19. });
  20. }
  21.  
  22.  
  23. #pragma mark - UIPickerViewDataSource
  24.  
  25. - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
  26. {
  27. return 1;
  28. }
  29.  
  30. - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
  31. {
  32. return self.userAccounts.count;
  33. }
  34.  
  35. #pragma mark - UIPickerViewDelegate
  36.  
  37. - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent: (NSInteger)component
  38. {
  39. ACAccount *account = (ACAccount *)self.userAccounts[row];
  40. NSString *username = [NSString stringWithFormat:@"@%@", account.username];
  41. return username;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement