问题
Xcode:Run>Show>Breakpoints
I've added the obligatory [NSExceptionRaise] and objc_exception_throw yet when I close the Breakpoints window and then return Xcode adds a third breakpoint: -[NSExceptionRaise]. Does this mean [NSExceptionRaise] is wrong and I should delete it? Or are they both helpful? If so in what way are they functionally different?
回答1:
The correct breakpoint is:
-[NSException raise]
You're instructing the debugger to break on the -raise method of the NSException class. "[NSExceptionRaise]" is (meaning no disrespect) nonsense. :-)
You don't need both, as far as I know. objc_exception_throw is the "new" way, whereas -[NSException raise] is the "old" way. I believe if you're on Leopard or later, only objc_exception_throw will be called. 10.4 or prior will call -[NSException raise].
回答2:
The newly added breakpoint is to -[NSException raise], which is distinct from [NSExceptionRaise] in that the latter is an object method (NSException being the class, raise being the message). I don't know what the latter is, and I suspect XCode is trying to be intelligent about what you entered v. what it thinks you meant.
回答3:
You have to preface the method with either a plus or minus character because the debugger uses the headers to locate and define the symbol. Different methods can have the same name but methods prefaced by a "+" are class methods and those prefaced by "-" are instance methods. Without the plus or minus the debugger has no idea what method you wanted.
来源:https://stackoverflow.com/questions/1798709/xcode-breakpoint-nsexceptionraise-vs-nsexceptionraise