应用程序崩溃使用Realm Swift

时间:2017-11-15 05:55:15

标签: ios swift realm

我已发送我的应用程序进行测试,并且使用crashlytics我发现了崩溃日志。 我不知道我可以告诉我的应用程序,它简单的表格视图,从Realm填充数据,就像那样。请查看崩溃日志:

Fatal Exception: Invalid value
0  CoreFoundation                 0x188efafd8 __exceptionPreprocess
1  libobjc.A.dylib                0x18795c538 objc_exception_throw
2  Realm                          0x1006ba570 RLMPrecondition(bool, NSString*, NSString*, ...) (RLMQueryUtil.mm:67)
3  Realm                          0x1007026b8 (anonymous namespace)::validate_property_value((anonymous namespace)::ColumnReference const&, objc_object*, NSString*, RLMObjectSchema*, NSString*) (RLMQueryUtil.mm:1071)
4  Realm                          0x1006bca28 (anonymous namespace)::QueryBuilder::apply_value_expression(RLMObjectSchema*, NSString*, objc_object*, NSComparisonPredicate*) (RLMQueryUtil.mm:1250)
5  Realm                          0x1006bb0d0 (anonymous namespace)::QueryBuilder::apply_predicate(NSPredicate*, RLMObjectSchema*) (RLMQueryUtil.mm:1452)
6  Realm                          0x1006ba62c RLMPredicateToQuery(NSPredicate*, RLMObjectSchema*, RLMSchema*, realm::Group&) (RLMQueryUtil.mm:504)
7  Realm                          0x10071c7f8 -[RLMResults objectsWithPredicate:] (RLMResults.mm:329)
8  RealmSwift                     0x100cf4c28 specialized Results.filter(String, [Any]...) -> Results<A> (Results.swift:208)
9  RealmSwift                     0x100cf212c Results.filter(String, [Any]...) -> Results<A> (Results.swift)
10 MyApp                          0x1000fbffc specialized ProductViewModel.init(m : Any, loginText : String, onAccountString : String, comissionString : String, fromClientString : String, commentString : String, amountVal : String, status : ProductResultItem.ResultStatus, errorTxt : String?, transId : Int?, shouldHideBackBtn : Bool, shouldAddModel : Bool, shouldModifyOperationWithId : Bool) -> ProductViewModel (ProductViewModel.swift:82)
11 MyApp                          0x1000da934 specialized ProductViewController.(simpleBtnCellTapped(type : SimpleBtnItem.ButtonType) -> ()).(closure #2) (ProductViewController.swift:249)
12 MyApp                          0x1000dcc4c partial apply for ProductViewController.(enterBtnLongTapEnteredText(enteredTxt : String) -> ()).(closure #1)
13 MyApp                          0x1000f5e74 ProductViewModel.(proceedTransfer(transactionResult : (ProductResultItem.ResultStatus, String?, Int?) -> ()) -> ()).(closure #1) empty-list Bool (ProductViewModel.swift:433)
14 MyApp                          0x1000e2388 ApiManager.(createOperation(parameters : [String : Any], complete : (Bool, String?) -> ()) -> ()).(closure #1) (ApiManager.swift:207)
15 Alamofire                      0x10037b944 specialized DataRequest.(response<A where ...> (queue : DispatchQueue?, responseSerializer : A, completionHandler : (DataResponse<A.SerializedObject>) -> ()) -> Self).(closure #1).(closure #1) (ResponseSerialization.swift:167)
16 Alamofire                      0x10035f5f4 thunk (NetworkReachabilityManager.swift)
17 libdispatch.dylib              0x187db29e0 _dispatch_call_block_and_release
18 libdispatch.dylib              0x187db29a0 _dispatch_client_callout
19 libdispatch.dylib              0x187db75e8 _dispatch_main_queue_callback_4CF
20 CoreFoundation                 0x188ea90c0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
21 CoreFoundation                 0x188ea6cdc __CFRunLoopRun
22 CoreFoundation                 0x188dd6d94 CFRunLoopRunSpecific
23 GraphicsServices               0x18a840074 GSEventRunModal
24 UIKit                          0x18f08f130 UIApplicationMain
25 MyApp                          0x1000668b8 main (AppDelegate.swift:18)
26 libdyld.dylib                  0x187de559c start

我想在哪里找到导致错误的原因?

1 个答案:

答案 0 :(得分:2)

从Realm的validate_property_value方法中引发的错误表明,在谓词中进行比较的值不是与要与之进行比较的属性兼容的类型。< / p>

异常消息(通常包含在崩溃日志中)应该准确地告诉您哪个属性和对象是问题所在。如果您没有这些信息,则应仔细查看执行查询的代码(ProductViewModel.init),看看是否可以确定不适当的对象类型的来源。