Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @property (weak, nonatomic) IBOutlet UIPickerView *myPickerView;
- @property (strong, readwrite, nonatomic) NSMutableArray *userAccounts;
- -(void)authenticateUser
- {
- [self populateDataSourceWithResultBlock:^(NSArray *accounts, NSError *error)
- {
- [self.twitterAccountPickerView reloadAllComponents];
- }];
- }
- - (void)populateDataSourceWithResultBlock:(void (^)(NSArray *accounts, NSError *error))resultBlock
- {
- self.userAccounts = [[NSMutableArray alloc] initWithObjects:@"one", @"two",nil];
- dispatch_sync(dispatch_get_main_queue(), ^{
- resultBlock(self.userAccounts, error);
- });
- }
- #pragma mark - UIPickerViewDataSource
- - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
- {
- return 1;
- }
- - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
- {
- return self.userAccounts.count;
- }
- #pragma mark - UIPickerViewDelegate
- - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent: (NSInteger)component
- {
- ACAccount *account = (ACAccount *)self.userAccounts[row];
- NSString *username = [NSString stringWithFormat:@"@%@", account.username];
- return username;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement