0

对 Coredata 存储不太熟悉。我想为一个single person and retrieve the data of a selected person. 像我一样,我将值存储在 coredata 表中,如下所示,

ID     Name    Date                 Report                  Status
1      Gopi    31 June 01.90pm      ABCD                    Y
2      Robot   27 June 2 am         hdfsdfk                 N
1      Gopi    31 June 02.00pm      fsdjk                   N
2      Robot   29 June 3am          eyrwruo                 Y
1      Gopi    1 July 3pm           rweyskd                 Y
1      Gopi    2 July 2pm           ABCD                    N
2      Robot   1 July 2.40pm        eirwierundfs            Y
3      John    2 July 10am          fewyrhhskd              Y
3      John    3 July 11am          sdkfksjfnvmnfks         N

在我的第一个视图控制器中,我想在 tableview 中显示这样的细节,

Gopi            2 July 2pm     >
ABCD            Y 
Robot           1 July 2.40pm  >
eirwierundfs    Y
John            3 July 11am    >
sdkfksjfnvmnfks Y

When the user selects Gopi, It will navigate to another view controller with table view and they can view all records of named Gopi. 而且我还想从实体中删除选定的用户详细信息。谁能帮我从 Coredata 获取唯一的用户详细信息?

我已将值存储在 coredata 实体中,并从实体中检索了所有行。但是,现在正在努力从实体中获取所选人员数据的唯一值。请你帮助我好吗?提前致谢。

4

1 回答 1

3

从核心数据中获取记录时添加这两行

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"Name==%@",str];
 //  Give your attribute name instead of "name"
 //  In str give the name "gopi" (for your case)  or whatever you want    

[fetchRequest setPredicate:predicate];
//set predicate to your fetch request

然后执行 fetch 请求

于 2012-07-03T06:41:36.600 回答