Face every mistake you encounter
In a small instance project of a remote control car toy, I used a combination of the remote control to have a car object (has a) relationship, not an inheritance (is a) relationship.
Idea: The instantiation process of creating a car is written in the initialization method of the remote control
CONTROLLER.M:
1 - (Instancetype) Initwith 2 3 self = [super Init]; 4 ( Self) { 5 NSLog (@ " remote initialization created ); 6 _car = [[Car alloc] init]; 7 8 return self; 9 }
Note: Here's the Init method, I accidentally wrote the Initwith method. The original intent is to customize the initialization method passed in parameters ... Forget to change back to Init.
Then, when creating the Controller object, use [[Controller alloc] init]. The result is called by the parent class (Controller extends NSObject) Init method, so the breakpoint is not found in the wrong, to a method will automatically jump out of the end.
Correct just put the wrong initwith back to the Init method.
Small instance of OC Error about Init method careless