Break on EXC_BAD_ACCESS in Xcode?

后端 未结 10 2108
北恋
北恋 2020-11-27 03:14

I\'m new to iPhone development and Xcode in general and have no idea how to begin troubleshooting an EXC_BAD_ACCESS signal. How can I get Xcode to break at the

10条回答
  •  渐次进展
    2020-11-27 03:36

    About your array. The line

    NSMutableArray *array = [NSMutableArray array];
    

    does not actually give you a retained object but rather an autorelease object. It probably gets retained in the next line but then you should not release it in the third line. See this

    This is the fundamental rule:

    You take ownership of an object if you create it using a method whose name begins with “alloc” or “new” or contains “copy” (for example, alloc, newObject, or mutableCopy), or if you send it a retain message. You are responsible for relinquishing ownership of objects you own using release or autorelease. Any other time you receive an object, you must not release it.

提交回复
热议问题