views:

377

answers:

1

Im doing an Iphone app with a UIPickerView. The picker view has two columns that contains NSStrings. I have a button that generates a NSString containing the selected value of both columns in the PickerView and prints it in the log.

The problem is that it only prints the first two items in the picker view even if i change the selected value.

and i also get a warning, "Format not a string literal and no format arguments". and i have no idea even though i checked google for clues.

heres the code for the button action:

- (IBAction) sendButtonTapped:(id)sender{
    NSString* theMessage = [NSString stringWithFormat:@"I'm %@ and feeling %@ about it.",
          [activities objectAtIndex:[tweetPicker selectedRowInComponent:0]],
          [feelings objectAtIndex:[tweetPicker selectedRowInComponent:1]]];
    NSLog(theMessage);
}
A: 

Log the selected row numbers to break down the problem:

NSLog(@"selectedRowInComponent0: %i", selectedRowInComponent:0);
NSLog(@"selectedRowInComponent1: %i", selectedRowInComponent:1);

Assuming that tweetPicker is an NSArray log it as well:

NSLog(@"tweetPicker: %@", tweetPicker);

It seems that NSLog wants a constant string for the first argument:

NSLog(@"%@", theMessage);

zaph
The problem with the selected values had to do with me not connecting my picker view with the outlet i created.thanks for the help with the NSlog problem!
Oscar