Debugging exception thrown in Objective-C and Xcode

前端 未结 5 851
梦毁少年i
梦毁少年i 2020-12-23 15:22

I am a long time Microsoft developer and I am new to iPhone development using Xcode. So, I am reading a book and going through examples trying to teach myself how to write

5条回答
  •  借酒劲吻你
    2020-12-23 16:20

    Always use the -Werror GCC setting (GCC_TREAT_WARNINGS_AS_ERRORS = YES). You should never have warnings in your code and this is an example where the warning is a critical error.

    Also, if you get an objc_exception_throw, switch to the console (Command-shift-R) and look for the first "low" number address.

    2009-04-01 13:25:43.385 CrashExample[41720:20b] Stack: (
        2528013804,
        2478503148,
        2528036920,
        2528053460,
        2358032430,
        11076,
        11880,
        816174880,
        345098340,
        145973440,
        816174880,
    )
    

    In this case it would be "11076". So type in the console:

    info line *11076
    

    That will tell you the line in your code where the exception was thrown.

提交回复
热议问题