2012-07-03 38 views
0

我不太熟悉Coredata存储。我想为single person and retrieve the data of a selected person保存多个数据。像明智的,我有存储值coredata表像下面,如何从Coredata iphone应用程序中获取唯一值?

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。而且我想从entitiy中删除选定的用户详细信息。任何人都可以帮助我从Coredata获得独特的用户细节吗?

我已经将值存储在coredata实体中,并从实体中检索到所有行。但是,现在我正努力从实体中获得选定人员数据的唯一值。你可以帮我吗?提前致谢。

+0

ü可以打印错误康寿 – Satyam

+0

我没有得到任何错误。我只想过滤来自coredata表格行的数据。请告诉我如何过滤来自coredata的数据?谢谢。 – Gopinath

回答

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 

然后执行读取请求

+0

Dinesh先生非常感谢您的回答。我现在会尝试它自己。可以从Coredata实体中删除选定的用户数据。你可以帮我吗。谢谢。 – Gopinath

+0

@Gopinath你真的读过关于CoreData的Apple文档吗?也许如果你阅读它,你将能够回答你自己的问题... https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdCreateMOs.html –

+0

是的您可以删除选定的用户数据。 使用谓词获取要删除的对象,然后删除该对象 –

相关问题