Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xmax

macrumors member
Original poster
Jul 3, 2008
33
0
Hello,

I want to have function name and class name on which Exception has been occurred.

is it possible to get class name and function name from exception ?
if yes , then how can i get it ?


Thanks.
 
Sorry,

I am talking about objective C , in Cocoa application.


Thanks.
 
As you can see in the NSException class reference there is no direct way to do this. If the object raising the exception chooses to it can include this information in the userInfo dictionary.

You can use the stackReturnAddresses to work out this sort of information, although this would take some work. Fortunately this work has been done for you as described in the documentation.

So, in short, read the documentation (in this case the obviously named Exception Programming Topics for Cocoa). The answer is almost always there.
 
Thanks for your reply. it really helped me lot.
I printed stack trace and it is giving me class file and its line number.
but i want all stack trace printed in string value.

is it possible to get NSString value for printed stack ?


Thanks.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.