gpt4 book ai didi

ios - 如何从嵌套数组中的 NSmutablearray 获取对象值?

转载 作者:行者123 更新时间:2023-11-29 00:41:16 24 4
gpt4 key购买 nike

我正在从 NSDictionary 中的 SQLite 获取数据,并将其转换为 NSMutableArray。现在我需要在 UITableViewCell 标签中添加该数组对象值。

arraydata (
{
UUID = 995443;
"group_id" = 41917;
name = "Maninderveer Kaur";
"roll_no" = 1;
"session_token" = bHKkctTPPyULIEy6rh4UKKTO9;
status = present;
"user_guid" = 995789;
},
{
UUID = 995445;
"group_id" = 41917;
name = "Manjot Kaur";
"roll_no" = 2;
"session_token" = bHKkctTPPyULIEy6rh4UKKTO9;
status = present;
"user_guid" = 995789;
},
{
UUID = 995447;
"group_id" = 41917;
name = "Prabhjot Sharma";
"roll_no" = 3;
"session_token" = bHKkctTPPyULIEy6rh4UKKTO9;
status = present;
"user_guid" = 995789;
},
{
UUID = 995449;
"group_id" = 41917;
name = "Prabhjot Singh";
"roll_no" = 4;
"session_token" = bHKkctTPPyULIEy6rh4UKKTO9;
status = present;
"user_guid" = 995789;
},
{
UUID = 995451;
"group_id" = 41917;
name = "Prince Parbhakar";
"roll_no" = 5;
"session_token" = bHKkctTPPyULIEy6rh4UKKTO9;
status = present;
"user_guid" = 995789;
},
{
UUID = 995453;
"group_id" = 41917;
name = "Puneet Kaur";
"roll_no" = 6;
"session_token" = bHKkctTPPyULIEy6rh4UKKTO9;
status = present;
"user_guid" = 995789;
},
{
UUID = 995455;
"group_id" = 41917;
name = "Rajveer Kaur";
"roll_no" = 7;
"session_token" = bHKkctTPPyULIEy6rh4UKKTO9;
status = present;
"user_guid" = 995789;
},
{
UUID = 995457;
"group_id" = 41917;
name = "Sahajpreet Kaur";
"roll_no" = 8;
"session_token" = bHKkctTPPyULIEy6rh4UKKTO9;
status = present;
"user_guid" = 995789;
},
{
UUID = 1824273;
"group_id" = 41933;
name = Ankit;
"roll_no" = 1104;
"session_token" = 9Ea6FqaIKgr9gZ5Gh6UWhVQTj;
status = present;
"user_guid" = 995789;
},
{
UUID = 1824271;
"group_id" = 41933;
name = Anuj;
"roll_no" = 1103;
"session_token" = 9Ea6FqaIKgr9gZ5Gh6UWhVQTj;
status = present;
"user_guid" = 995789;
},
{
UUID = 995695;
"group_id" = 41933;
name = "Anureet Kaur";
"roll_no" = 14;
"session_token" = 9Ea6FqaIKgr9gZ5Gh6UWhVQTj;
status = present;
"user_guid" = 995789;
},
)

我已经通过这一行在单元格扩展标签上添加了数据。

cell.stdntName.text = [array valueForKey:@"name"];

在单元格标签上添加值时出现此错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0x7ffcab275550'.

我认为以上细节还可以。请在我出错的地方提出一些建议。

最佳答案

根据索引路径从数组中提取特定字典,然后从该字典中获取值。

试试这个:

NSDictionary *dict = array[indexPath.row]
cell.stdntName.text = [dict valueForKey:@"name"];

关于ios - 如何从嵌套数组中的 NSmutablearray 获取对象值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39443904/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com