nsexception

How to find instance by hex in XCode console?

假如想象 提交于 2019-11-29 11:31:49
问题 When I bring up console after my iPhone app crashes, it often says "unrecognized selector sent to instance 0x blah blah blah." How can I find out what variable this is? Is there a way in the debugger? Is it even possible? Thanks. 回答1: In gdb you could type po 0x12345678 to print the -description of the object at that address. But this info is seldom useful. You should instead check the backtrace of the exception first, which can locate the line of code that causes the problem. 回答2: It's very

How to properly handle NSFileHandle exceptions in Swift 2.0?

守給你的承諾、 提交于 2019-11-29 06:22:26
问题 First of all, I am new to iOS and Swift and come from a background of Android/Java programming. So to me the idea of catching an exception from an attempt to write to a file is second nature, in case of lack of space, file permissions problems, or whatever else can possibly happen to a file (and has happened, in my experience). I also understand that in Swift, exceptions are different from Android/Java ones, so that's not what I'm asking about here. I am attempting to append to a file using

@try - catch block in Objective-C

半世苍凉 提交于 2019-11-28 03:09:57
Why doesn't @try block work? It crashed the app, but it was supposed to be caught by the @try block. NSString* test = [NSString stringWithString:@"ss"]; @try { [test characterAtIndex:6]; } @catch (NSException * e) { NSLog(@"Exception: %@", e); } @finally { NSLog(@"finally"); } All work perfectly :) NSString *test = @"test"; unichar a; int index = 5; @try { a = [test characterAtIndex:index]; } @catch (NSException *exception) { NSLog(@"%@", exception.reason); NSLog(@"Char at index %d cannot be found", index); NSLog(@"Max index is: %lu", [test length] - 1); } @finally { NSLog(@"Finally condition"

Terminating with uncaught exception of type NSException? [closed]

放肆的年华 提交于 2019-11-27 21:15:15
My application crashes when clicking a button to go to segue into a new view. This comes up: int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } "return UIApplicationMain..." is highlighted in green with "Thread 1: Signal SIGABRT" at the end. The error also includes this in the output: **Terminating app due to uncaught exception *** 'NSUnknownKeyException reason:'[<SlopeViewController 0x8b68c70> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key m.' *** First throw call

NSUnknownKeyException setValue:forUndefinedKey: [duplicate]

泄露秘密 提交于 2019-11-27 14:46:13
This question already has an answer here: Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error? 66 answers Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key buttonOfFirstView.' Why do I get this error? I am trying to make a table cell though XIB. After I add this code it throws the above exception. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString

Usage of NSException in iPhone Apps

喜欢而已 提交于 2019-11-27 11:44:08
One of my friends asked me not to use NSException in iPhone Apps. The reason he gave was "performance bottleneck". But I am not convinced of it. Can someone confirm me that we should restrain from using NSException in iPhone App? If you have best practices for using NSException, please provide that too. UPDATE: This link requests us to use Exception handling at the app level. Have someone ever done it? Please give the advantages of it and any other performance hitches it could create. In short: Do not use exceptions to indicate anything but unrecoverable errors It is only appropriate to use

Terminating with uncaught exception of type NSException? [closed]

喜你入骨 提交于 2019-11-26 20:35:26
问题 My application crashes when clicking a button to go to segue into a new view. This comes up: int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } "return UIApplicationMain..." is highlighted in green with "Thread 1: Signal SIGABRT" at the end. The error also includes this in the output: **Terminating app due to uncaught exception *** 'NSUnknownKeyException reason:'[<SlopeViewController 0x8b68c70> setValue

NSUnknownKeyException setValue:forUndefinedKey: [duplicate]

泪湿孤枕 提交于 2019-11-26 18:26:47
问题 This question already has an answer here: Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error? 67 answers Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key buttonOfFirstView.' Why do I get this error? I am trying to make a table cell though XIB. After I add this code it throws the above exception. -

Xcode doesn&#39;t show the line that causes a crash

拥有回忆 提交于 2019-11-26 14:16:37
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 line just right with older SDKs but since i upgraded to Xocde 4.2 that changed. It is pretty obvious that

Catching NSException in Swift

霸气de小男生 提交于 2019-11-26 11:16:30
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 freytag Here is some code, that converts NSExceptions to Swift 2 errors. Now you can use do { try ObjC.catchException {