开发者

Objective c Setting picker value from NSDictionary

开发者 https://www.devze.com 2023-03-13 00:04 出处:网络
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 tr

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 = (NSDiction开发者_运维百科ary*)[myEnumerator nextObject])
{
    [myPickerView selectRow:[myItem objectForKey:@"Value"] inComponent:i animated:YES];
    i++;
}


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];


The selectRow parameter is expecting an integer, try this:

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

精彩评论

暂无评论...
验证码 换一张
取 消