0

I have this code which will send me to another page but this only happens upon selecting a row in the picker.

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
    NSString *urlString;
    if (row == 0) {            
                urlString = @" ";
                [self loadData:urlString];
            }

However, I have an alert view which is suppose to execute this code when I click on a certain row. Each of my row has a different url thus, I need to do this if (row == 0) code.

Is there anyway I can add the code above to my alert code below?

   -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

    if (buttonIndex == 1) {
        }
    }

Those two codes above are working perfectly fine. I am only figuring out whether is it even possible to add in the didSelectRow code into the alertview code. Please help!

SaharaLALA
  • 13
  • 5

1 Answers1

0

Unless I don't fully understand what you're asking, there should be no problem transferring the above code to the alert view method.

Just use:

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

if (buttonIndex == 1) {

    NSInteger row =[ pickerView selectedRowInComponent:0];
    NSString *select = [pickerViewArray objectAtIndex:row];
    NSString *urlString;

    if (select == @"  " ) {

        urlString = @" ";
    [self loadData:urlString];
    }
}
}
}
The Kraken
  • 3,158
  • 5
  • 30
  • 67
  • ermm.. Ok. My picker has different rows right.. and each row is suppose to load different urlString. But the answer that you just posted above will load only 1 kind of urlString upon me clicking "Select" at my alertView.. get it? What I am stuck with is that when I click the "Select" button on my alertView, the codes in my "didSelectRow" will execute.. Thanks anyway for replying(: – SaharaLALA Aug 13 '12 at 03:23
  • Hey @The Kraken I've solved it ^^ I kindda used the answer that you have given above! Just did some amendments here and there and the idea was there.. Thank you very much(: – SaharaLALA Aug 13 '12 at 04:57