rich
rich

Reputation: 1227

Objective c Setting picker value from NSDictionary

Another, probably simple problem that, having tried for a good few hours now I'm pretty stumped on. Simply, I want to set the value of a picker from a NSDictionary, I don't mind! Every way I have tried pretty much gives me the warning Passing argument 1 of selectRow inComponent animated' makes integer from pointer witout a cast. Which makes sense, though I seem to be failing miserable at fixing it! Any help would be greatly appreciated! Snippet of code below...

NSArray *myValue = [parsedJson objectForKey:@"Details"];
NSEnumerator *myEnumerator = [myValue objectEnumerator];
NSDictionary* myItem;

int i = 0;
while (myItem = (NSDictionary*)[myEnumerator nextObject])
{
    [myPickerView selectRow:[myItem objectForKey:@"Value"] inComponent:i animated:YES];
    i++;
}

Upvotes: 2

Views: 717

Answers (2)

BP.
BP.

Reputation: 10083

The selectRow parameter is expecting an integer, try this:

[myPickerView selectRow:[[myItem objectForKey:@"Value"] integerValue] inComponent:i animated:YES];

Upvotes: 2

Vladimir
Vladimir

Reputation: 170849

Assuming your value responds to intValue message (e.g. number is stored in NSNumber or NSString) then the following should work:

[myPickerView selectRow:[[myItem objectForKey:@"Value"] intValue]
            inComponent:i animated:YES];

Upvotes: 2

Related Questions