3 ms·
Is this the first time a feature is exclusive to swift, and not available for Objective-C? I wish they would offer this for regular Objective-C apps as well. UI
by 0x0 9y ago
Is this the first time a feature is exclusive to swift, and not available for Objective-C? I wish they would offer this for regular Objective-C apps as well. UIApplication is an objc class after all!
- Someone 9y agoObjective-C is C; it doesn’t do the various range and nil checks that Swift does to exit properly. Because of that, it cannot do that.
- nielsbot 9y agonot entirely true. if you use Obj-C data types (NSArray etc) you get an exception for out-of-range accesses.
- 0x0 9y agoRight, I feel like I've seen exceptions for a lot of errors ending up with xcode hanging on an exc_bad_whatever disassembly of some sort of main() routine, things like putting nil values in arrays, inconsistent uitableview datasource implementations, etc. Usually shows an alright stack trace logged to the console but the main xcode editor still opens a useless disassembler in system code?
- eridius 9y agoStick `po $arg1` in your exception breakpoint and it will print the exception (well, for Obj-C exceptions; I don't remember offhand how to look at C++ exceptions since I so rarely deal with them).
- 0x0 9y agoThanks for the tip. It's usually not a problem to figure out what's wrong (the exception is dumped to the debugger), but it's a bit useless that the main editor in xcode switches to an irrelevant disassembly view at the same time :)
- eridius 9y agoIt shouldn't. Xcode usually switches to the shallowest stack frame that has source code available when hitting a breakpoint.
- 0x0 9y agoOh, I was talking about uncaught exceptions where no breakpoint has been set.
- eridius 9y agoUncaught exceptions don't enter the debugger until it bubbles back up to main(), so the stack in the debugger is useless there.
- 0x0 9y agoRight, I was hoping this new Xcode 9.1 feature could improve upon that for Objective-C as well. Perhaps capturing a copy of the stack when the exception is raised, so it open the main editor window on the appropriate source line where that exception was raised.
- hawflakes 9y agoObj-C got _Nonnull and _Nullable type annotations as hints to the compiler. Presumably those checks could get compiled in as well? https://developer.apple.com/swift/blog/?id=25 https://developer.apple.com/swift/blog/?id=25
- eridius 9y agoIt's not available for Obj-C because this has to do with a Swift-only feature. The closest equivalent in Obj-C is throwing exceptions.