Objective c 从 NSDictionary 设置选择器值
另一个可能很简单的问题,在尝试了好几个小时后,我现在很困惑。简单地说,我想从 NSDictionary 设置选择器的值,我不介意!我尝试过的每种方法几乎都会给我警告传递 selectRow inComponentAnimated 的参数 1 使指针中的整数不进行强制转换。这是有道理的,尽管我似乎无法修复它!任何帮助将不胜感激!下面的代码片段...
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++;
}
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++;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您的值响应 intValue 消息(例如,数字存储在 NSNumber 或 NSString 中),那么以下操作应该有效:
Assuming your value responds to intValue message (e.g. number is stored in NSNumber or NSString) then the following should work:
selectRow 参数需要一个整数,请尝试以下操作:
The selectRow parameter is expecting an integer, try this: