There are a lot of problems in the app development process, and various crashes can be quite frustrating. Of course, the ability to solve bugs also reflects the level of a programmer, and now it's time to talk about the crash problems that are often encountered in development.
Common crash problems: one is signal SIGABRT, two is exc_bad_access.
First, signal SIGABRT There are two reasons for such a crash: 1. Array out of bounds
Input:
*array = [Nsarray arraywithobject:@ "0"]; *STR = [Array objectatindex:1]; NSLog (@ "%@", str);
Run crash:
Crash Information for printing:
Terminating app due to uncaught exception ' nsrangeexception ', Reason: ' * * *-[__nsarrayi Objectatindex:]: Index 1 beyond Bo unds [0.. 0] ', it is obvious that the crash information given is an array out of bounds, this time to carefully examine the problem of array in the program
2. The calling method does not exist:
Input:
[Self performselector: @selector (haha)];
Run crash, crash information:
Unrecognized selector sent to instance 0X7FCD584A1AE0
Terminating app due to uncaught exception ' nsinvalidargumentexception ', Reason: '-[viewcontroller haha]: Unrecognized sel Ector sent to instance 0x7fcd584a1ae0 '
Indicates that the method does not exist, so it causes a crash
Second, exc_bad_access is generally a memory access error, the object memory has been released, but still access will cause such consequences
For example, when making a video,
generator is the picture resource generator [Generator generatecgimagesasynchronouslyfortimes:@[ Currentsniptime] Completionhandler: ^ (cmtime requestedtime, cgimageref _nullable image, Cmtime actualTime, Avassetimagegeneratorresult result, nserror * _nullable error) {NSLog (@ " build complete ); // main thread update UI if it is an asynchronous task: Continue execution in the current thread, Instead of waiting for the code block to complete, that is, skipping the assignment code, causing the wild pointer Dispatch_sync (Dispatch_get_main_queue (), ^{ // exc_bad_access wild pointer accesses a memory address that cannot be used self.snipImageView.image = [UIImage Imagewithcgimage:image]; }); }];
So when information such as Exc_bad_access appears in the crash message, you can analyze which properties are modified with weak, or thread async/sync issues. Of course, we can also use the Xcode tool to click on the Xcode menu: Product->profile, launch instruments in the instruments template to select Zombies, it can temporarily retain the freed memory, the re-visit will report an error, and give the block memory used some information, help us quickly locate.
Xcode crash problem Debug Signal sigabrt&exc_bad_access