NSFetchRequest *request = [[NSFetchRequest alloc] init];NSEntityDescription *entity = [NSEntityDescription entityForname:@"Session" inManagedobjectContext: ctx];[request setEntity:entity];// Specify that the request should return dictionarIEs.[request setResultType:NSDictionaryResultType];// Create an Expression for the key path.NSExpression *keyPathExpression = [NSExpression ExpressionForKeyPath:@"startedAt"];// Create an Expression to represent the minimum value at the key path 'creationDate'NSExpression *minExpression = [NSExpression ExpressionForFunction:@"min:" arguments:[NSArray arrayWithObject:keyPathExpression]];// Create an Expression description using the minExpression and returning a date.NSExpressionDescription *ExpressionDescription = [[NSExpressionDescription alloc] init];// The name is the key that will be used in the dictionary for the return value.[ExpressionDescription setname:@"minDate"];[ExpressionDescription setExpression:minExpression];[ExpressionDescription setExpressionResultType:NSDateAttributeType];// Set the request's propertIEs to fetch just the property represented by the Expressions.[request setPropertIEsToFetch:[NSArray arrayWithObject:ExpressionDescription]];// Execute the fetch.NSError *error;NSArray *objects = [ctx executeFetchRequest:request error:&error];@H_301_7@而错误: @H_301_7@
-[NSCalendarDate count]: unrecognized selector sent to instance ...@H_301_7@鉴于1)NSCalendarDate已弃用且2)我绝对不会调用count,这很奇怪. @H_301_7@非常感激任何的帮助!解决方法 为什么不添加一个排序描述符来按beginDate升序排序,然后只让fetch请求返回1个对象? 总结
以上是内存溢出为你收集整理的cocoa – 核心数据:试图找到实体中属性的最小日期全部内容,希望文章能够帮你解决cocoa – 核心数据:试图找到实体中属性的最小日期所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)