核心数据 NSFetchedResultsController:在设备上调试时出错(无法为谓词生成 SQL)
当我在设备上调试我的应用程序时,我遇到了一个奇怪的异常。在模拟器中调试按预期工作。
- 我使用核心数据来存储模型中的数据
- 关系,如下所示:位置<->位置详情->> HappyHour
- 我使用 NSFetchedResultsController 来填充 UITableView
- 我对 Objective-C 开发也很陌生,
我需要有一个 SUBQUERY 来获取 HappyHour 实体的属性。
像这样:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(0 != SUBQUERY(details.%K, $hh, ($hh.startTime < %@) AND ($hh.endTime > %@)).@count)", weekdayString, theDate, theDate];
仅在设备上我收到此错误/异常:
* 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“无法为谓词生成 SQL (0 != SUBQUERY(details.hh_montag) , $hh, $hh.startTime < CAST(316482000.000000, "NSDate") AND $hh.endTime > CAST(316482000.000000, "NSDate")).@count) (RHS 上的问题)'
0 CoreFoundation 0x32cf964f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x3313cc5d objc_exception_throw + 24
2 CoreData 0x3228a829 -[NSSQLGenerator newSQLStatementForFetchRequest:ignoreInheritance:countOnly:nestingLevel:] + 688
3 CoreData 0x3228a2eb -[NSSQLAdapter _newSelectStatementWithFetchRequest:ignoreInheritance:] + 378
4 CoreData 0x3228a169 -[NSSQLAdapter newSelectStatementWithFetchRequest:] + 16
5 CoreData 0x3228a005 -[NSSQLCore newRowsForFetchPlan:] + 288
6 CoreData 0x322892c5 -[NSSQLCore 对象ForFetchRequest:inContext:] + 420
7 CoreData 0x32288875 -[NSSQLCoreexecuteRequest:withContext:error:] + 304
8 CoreData 0x32287dd5 -[NSPersistentStoreCoordinatorexecuteRequest:withContext:error:] + 896
9 CoreData 0x3228669f - [NSManagedObjectContextexecuteFetchRequest:错误:] + 374
10 CoreData 0x322b9d7f -[NSFetchedResultsController PerformFetch:] + 766
11 HappyHourRadar 0x0003e723 -[ResultViewController viewDidLoad] + 86
...
抛出“NSException”实例后调用终止 收到信号:SIGABRT(已中止)
进程已完成,退出代码为 -1
在 [ResultViewController viewDidLoad] +86
我
调用[self fetchedResultsController] PerformFetch:&error]
在控制台中 我还收到此消息:
无法加载符号文件:无法加载符号文件:警告:无法读取 /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 的符号(8J2)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib(未找到文件)。
因为我没有找到任何可以帮助我的东西,我想这要么是一些非常奇怪的东西,要么我只是搞砸了一些相当标准的东西,由于我有限的目标c背景,我找不到......
无论如何,我会非常高兴如果有人能给出提示,这样我就可以继续,而不必将整个应用程序模型层重写为肮脏的东西(例如获取所有条目并将它们保存在数组中并处理过滤器函数......类似的东西;))
编辑:
这是模型图。由此自动生成模型文件。
生成的 HappyHour 类:
@interface HappyHour : NSManagedObject
{
}
@property (nonatomic, retain) NSDate * endTime;
@property (nonatomic, retain) NSDate * startTime;
@end
i have a weird exeption when i debug my app on my device. debugging in simulator works as expected.
- i use core data for storing my data
- relationships in model are as follows: Location <-> LocationDetails ->> HappyHour
- i use NSFetchedResultsController to populate a UITableView
- i'm also pretty new to objective-c develpoment
i need to have a SUBQUERY to get to the attributes of the HappyHour entity.
Like this:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(0 != SUBQUERY(details.%K, $hh, ($hh.startTime < %@) AND ($hh.endTime > %@)).@count)", weekdayString, theDate, theDate];
ONLY on the DEVICE i get this error/exeption:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to generate SQL for predicate (0 != SUBQUERY(details.hh_montag, $hh, $hh.startTime < CAST(316482000.000000, "NSDate") AND $hh.endTime > CAST(316482000.000000, "NSDate")).@count) (problem on RHS)'
0 CoreFoundation 0x32cf964f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x3313cc5d objc_exception_throw + 24
2 CoreData 0x3228a829 -[NSSQLGenerator newSQLStatementForFetchRequest:ignoreInheritance:countOnly:nestingLevel:] + 688
3 CoreData 0x3228a2eb -[NSSQLAdapter _newSelectStatementWithFetchRequest:ignoreInheritance:] + 378
4 CoreData 0x3228a169 -[NSSQLAdapter newSelectStatementWithFetchRequest:] + 16
5 CoreData 0x3228a005 -[NSSQLCore newRowsForFetchPlan:] + 288
6 CoreData 0x322892c5 -[NSSQLCore objectsForFetchRequest:inContext:] + 420
7 CoreData 0x32288875 -[NSSQLCore executeRequest:withContext:error:] + 304
8 CoreData 0x32287dd5 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 896
9 CoreData 0x3228669f -[NSManagedObjectContext executeFetchRequest:error:] + 374
10 CoreData 0x322b9d7f -[NSFetchedResultsController performFetch:] + 766
11 HappyHourRadar 0x0003e723 -[ResultViewController viewDidLoad] + 86
...
terminate called after throwing an instance of 'NSException'
Signal received: SIGABRT (Aborted)
Process finished with exit code -1
At [ResultViewController viewDidLoad] +86
i call
[self fetchedResultsController] performFetch:&error]
in the console i also get this message:
unable to load symbol file: unable to load symbol file: warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
As i haven't found anything that could help me, i guess it's either something really weird, or i just messed up something pretty standard, that i can't find because of my limited objective c background...
Anyway, i would be very glad if someone could give a hint, so i can continue without having to rewrite my entire application model layer to something dirty (like fetching all entries and holding them in an array and process filter functions...stuff like that ;) )
edit:
here is the model graph. from this auto-generated the model files.
generated HappyHour class:
@interface HappyHour : NSManagedObject
{
}
@property (nonatomic, retain) NSDate * endTime;
@property (nonatomic, retain) NSDate * startTime;
@end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想通了。希望这能帮助那些像我一样盲目、疲倦或其他什么的人。 ;)
这些粗体标记的段落显然不匹配:
和
最终的解决方案是:
黄金法则:
始终记住,设备在不同的位置/语言中会有不同的工作方式。
因此,也许可以避免从依赖于位置/语言的类(如 NSDate(Formatter))生成键选择器(?)。
或者确保这些类对于每种情况都返回相同的值。 (希望我已经用这个解决方案解决了一些问题......如果我弄错了,请纠正我。)
i figured it out. Hopefully this will help someone, who is as blind, tired or whatever as myself. ;)
These bold marked passages clearly don't match:
and
The final solution was:
Golden Rule:
Always keep in mind, that a device will work differently in a different location/language.
So, maybe avoid producing key selectors(?) from location/language-dependent classes like NSDate(Formatter).
Or make sure, that these classes return the same values for every case. (Hopefully something I have taken care of with this solution...correct me if I got that wrong.)