1
A
回答
2
我假设你有一个fetchedResultsController设置为从数据库中检索对象。 当您设置fetchedResultsController时,您必须将NSPredicate添加到您的fetchRequest。
日期无耻地从here
//You can set up your custom dates like this
NSDate *today = [NSDate date];
NSDate *yesterday = [today addTimeInterval: -86400.0];
NSDate *thisWeek = [today addTimeInterval: -604800.0];
NSDate *lastWeek = [today addTimeInterval: -1209600.0];
// This predicate retrieves all the object created since last week.
NSpredicate *predicate = [NSPredicate predicateWithFormat:@"yourDateField >= %@ ", lastWeek];
[fetchRequest setPredicate:predicate];
// You can add sorting like this
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"yourDateField" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
希望这有助于被盗。如果您有任何问题,请告诉我。
相关问题
- 1. CoreData:按日期
- 2. Coredata NSPredicate按日期
- 3. 按日期搜索范围
- 4. mysql表按日期搜索
- 5. CoreData搜索RestKit
- 6. 按日期SQL服务器搜索2005
- 7. 使用命令行按日期搜索
- 8. 如何在PGSQL中按日期搜索?
- 9. SQL,按日期搜索,不存在
- 10. wordpress按日期排序搜索结果
- 11. 按日期搜索Mysql查询
- 12. 在DBIx上按日期搜索::类
- 13. Bing Azure API按日期范围搜索
- 14. 必应搜索API:按日期缩小
- 15. 按日期JIRA JQL搜索 - 如何搜索1小时
- 16. NSPredicate iphone coredata搜索
- 17. 搜索CoreData关系
- 18. 如何按日期和日期搜索模型
- 19. 从日期搜索数据库日期
- 20. thinking_sphinx嵌套日期搜索
- 21. 日期搜索Sql查询
- 22. 如何从日期搜索?
- 23. Yii2日期范围搜索
- 24. 搜索日期与条件
- 25. IMAP搜索 - 日期范围
- 26. SQL Server 2008搜索日期
- 27. 搜索原始日期 - MYSQL
- 28. Ruby on Rails:日期搜索
- 29. 搜索日期的问题
- 30. PHP搜索SQL DB日期