如何获取唯一值从Coredata iphone应用程序检索? [英] How to get unique values retrieve from Coredata iphone app?
问题描述
在Coredata存储中不太熟悉。我要为单个人保存多个数据,并检索所选人员的数据
。很聪明的我在coredata表的商店价值如下,
ID名称日期报告状态
1 Gopi 31六月01.90 pm ABCD Y
2机器人27六月2 am hdfsdfk N
1 Gopi 31六月02.00pm fsdjk N
2机器人29 6月3日eyrwruo Y
1 Gopi 1 7月3日下午rweyskd Y
1 Gopi 2 7月2pm ABCD N
2机器人1 7月2日下午4时eirwierundfs Y
3约翰2月7日10am fewyrhhskd Y
3约翰·3月11日sdkfksjfnvmnfks N
在我的第一个视图控制器中,我想在tableview中显示这样的细节,
Gopi 2 July 2pm>
ABCD Y
Robot 1 July 2.40pm>
eirwierundfs Y
John 3 July 11am>
sdkfksjfnvmnfks Y
当用户选择Gopi时,到具有表视图的另一个视图控制器,并且他们可以查看命名为Gopi
的所有记录。而且我想从entitiy删除所选的用户详细信息。任何人都可以帮助我从Coredata获取唯一的用户详细信息?
我已经将值存储在coredata实体中,并从实体检索所有行。但是,现在很难从实体获取所选人员数据的唯一值。你可以帮我吗?提前感谢。
解决方案从核心数据获取记录时,添加这两行
NSPredicate * predicate = [NSPredicate predicateWithFormat:@Name ==%@,str];
//给你的属性名称而不是name
//在str中给出名称gopi(你的case)或任何你想要的
[fetchRequest setPredicate:谓词];
//将谓词设置为您的提取请求
然后执行fetch请求
Am not well familiar in Coredata storage. I want to save multiple data for a single person and retrieve the data of a selected person
. Like wise i have store values in coredata table like below,
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
In my first view controller i want to show the details like this in 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
. And also i want to delete the selected user details from the entitiy. Can anyone please help me to get a unique user details from Coredata?
I have stored the values in coredata entity and retrieved all the rows from the entity. But, now am struggling to get a unique values of selected person data from the entity. Could you please help me? Thanks in advance.
解决方案 While fetching record from core data add these two lines
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
Then execute fetch request
这篇关于如何获取唯一值从Coredata iphone应用程序检索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!