Tag: 例外

从Objective-C引发exception返回到Javascript

JavascriptCore允许我们通过JSExport协议将我们的Objective-C类暴露给javascript。 比方说,在其中一个公开的Objective-C类的方法中,遇到了引发exception的情况。 有没有办法创build所述的exception,并提出这样的JavaScript代码可以处理它,因为它会处理一个正常的JavaScriptexception? 我试着做一个常规的[NSException raise…]并立即造成了崩溃。 我降级检测提出条件,将该条件传回到JavaScript,并让JavaScript做抛出?

UIPickerView iOS7.1中未定义的键NSException

我在7.0版本中没有出现iOS 7.1模拟器中的exception。 它似乎在核心的某处处理,因为它只触发exception引发断点。 它不会login到控制台或崩溃。 这在滚动UIPickerView中的选项时发生。 没有有意义的回溯(从UIApplicationMain到objc_exception_throw),但是在debugging器中抛出时检查exception显示: [<UIPickerView 0xb9a6700> valueForUndefinedKey:]: this class is not key value coding-compliant for the key _mode. 我在我的项目searchmode , setMode: , mode =但我不认为我是一个设置这个。 其他人遇到这个? 我想如果没有崩溃的应用程序是好的,但它给了我一个恐慌,我宁愿采取行动,以防止它被抛出。 如果我有更多的时间,我会尝试在testing项目中进行隔离并跟进。 编辑:更好的回溯: thread #1: tid = 0x10975c, 0x02590909 libc++abi.dylib`__cxa_throw, queue = 'com.apple.main-thread, stop reason = breakpoint 1.2 frame #0: 0x02590909 libc++abi.dylib`__cxa_throw frame #1: 0x01b1d9fc libobjc.A.dylib`objc_exception_throw + 323 […]

如何使用NSSetUncaughtExceptionHandler在Swift中的UIView上显示exception消息

我使用Martin R的答案在Swift中打印NSSetUncaughtExceptionHandler。 我应该如何在Swift中使用NSSetUncaughtExceptionHandler func exceptionHandler(exception : NSException) { let alert = UIAlertController(title: "Exception", message: "\(exception)", preferredStyle: .Alert) self.presentViewController(alert, animated: true, completion: nil) print(exception) print(exception.callStackSymbols) } 但是我怎样才能显示消息在UIView。 像这个 因为我得到了一个编译器的错误消息,说“AC函数指针只能由引用'func'或文字闭包形成。 处理 Matt Gallagher在Cocoa with Love编写的未处理的exception和信号 。

领域与RLMException崩溃:对象已被删除或无效

我有一个存储时间线的领域模型(我正在制作video编辑应用程序),而且经常碰到访问它的RMArray属性。 该应用程序已经发货,我没有经历过自己,但我crushlytics通知我经常这样的崩溃。 这是崩溃日志: Fatal Exception: RLMException Object has been deleted or invalidated. Thread : Fatal Exception: RLMException 0 CoreFoundation 0x2614d45f __exceptionPreprocess + 126 1 libobjc.A.dylib 0x3407ec8b objc_exception_throw + 38 2 VideoEditor 0x00293919 RLMGetArray(RLMObjectBase*, unsigned int, NSString*) (RLMRealm_Private.hpp:38) 3 VideoEditor 0x0018a1b4 VideoEditor.RLMProject.setTimeLineModel (VideoEditor.RLMProject)(VideoEditor.TimeLineModel, beginWriteTransaction : Swift.Bool) -> () (RealmModels.swift:147) 4 VideoEditor 0x0025eb9c VideoEditor.VideoEditorAPI.saveProject (VideoEditor.VideoEditorAPI)(Swift.Optional<VideoEditor.IProject>, timeLine : […]

在dispatch_semaphore_dispose上的EXC_BAD_INSTRUCTION(code = EXC_I386_INVOP,子码= 0x0)

我在dispatch_semaphore_dispose上得到了EXC_BAD_INSTRUCTION(code = EXC_I386_INVOP,subcode = 0x0),但是并不知道如何find这个的根本原因。 我的代码使用dispatch_async,dispatch_group_enter等。 更新:崩溃的原因是因为webserviceCall(请参阅下面的代码)永远不会调用onCompletion,并再次运行代码时,我得到了错误EXC_BAD_INSTRUCTION。 我证实这确实是这样,但不知道为什么或如何防止这种情况。 码: dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0); dispatch_group_t group = dispatch_group_create(); for (…) { if (…) { dispatch_group_enter(group); dispatch_async(queue, ^{ [self webserviceCall:url onCompletion:^{ dispatch_group_leave(group); }]; }); } } dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_group_wait(group, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC))); dispatch_sync(queue, ^{ // call completion handler passed in by caller }); });