nsexception

Xcode doesn't show the line that causes a crash

空扰寡人 提交于 2019-11-26 03:49:55
问题 Every time my app crashes Xcode highlights the UIApicationMain() call in the main() function as the line that caused the crash. In some cases that used to be normal (segmentation fault for example) but the crash I am trying to deal with is a simple SIGABRT with detailed information logged in the console: *** Terminating app due to uncaught exception \'NSInvalidArgumentException\', reason: \'-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: Date)\' Xcode used to show the

Catching NSException in Swift

南楼画角 提交于 2019-11-26 01:58:52
问题 The following code in Swift raises NSInvalidArgumentException exception: task = NSTask() task.launchPath = \"/SomeWrongPath\" task.launch() How can I catch the exception? As I understand, try/catch in Swift is for errors thrown within Swift, not for NSExceptions raised from objects like NSTask (which I guess is written in ObjC). I\'m new to Swift so may be I\'m missing something obvious... Edit : here\'s a radar for the bug (specifically for NSTask): openradar.appspot.com/22837476 回答1: Here