Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何从按对象创建日期排序的核心数据中获取结果?_Ios_Objective C_Nsfetchedresultscontroller_Nsfetchrequest - Fatal编程技术网

Ios 如何从按对象创建日期排序的核心数据中获取结果?

Ios 如何从按对象创建日期排序的核心数据中获取结果?,ios,objective-c,nsfetchedresultscontroller,nsfetchrequest,Ios,Objective C,Nsfetchedresultscontroller,Nsfetchrequest,对不起,如果标题不清楚,我会解释: 我有一个便笺创建页面,创建便笺后,我将使用模型类(nsmanagedobject子类)保存便笺 我有另一个表视图控制器,我正在显示注释,我希望表视图上的注释按创建日期排序,有键吗 这就是我现在拥有的: NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"body" ascending:YES]; 这里的关键是注释的文本,所以它是按abc排序的,你能帮我按日期排序

对不起,如果标题不清楚,我会解释:

我有一个便笺创建页面,创建便笺后,我将使用模型类(nsmanagedobject子类)保存便笺

我有另一个表视图控制器,我正在显示注释,我希望表视图上的注释按创建日期排序,有键吗

这就是我现在拥有的:

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"body" ascending:YES];
这里的关键是注释的文本,所以它是按abc排序的,你能帮我按日期排序吗


tnx

托管对象没有隐式的创建日期属性。您可以在模型中创建属性,例如creationDate,并在创建对象时将其设置为
[NSDate]

然后,您可以简单地根据该属性进行排序

 NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"creationDate" ascending:YES];

托管对象没有隐式的创建日期属性。您可以在模型中创建属性,例如creationDate,并在创建对象时将其设置为
[NSDate]

然后,您可以简单地根据该属性进行排序

 NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"creationDate" ascending:YES];

你的实体上有没有像creationDate这样的属性?你的实体上有没有像creationDate这样的属性?