Wednesday, September 25, 2013

objC declare variables and the use of problem

In the h file
@ Interface player {
UIView * view;
}
@ Property (nonatomic, retain) UIView * view;

Seen in the m file often used this way
@ Synthesize view;
self.view = [[UIView alloc] init ...] / / 1. using ARC mechanism, it will not cause the view here retainCount is 2?
[View message]; / / 2. Use are used directly after the variable name, and use self.view is this any different, or is it just a way to write fewer letters, easy to write?
Reply:
self.view = [[UIView alloc] init ...] / / 1. using ARC mechanism, it will not cause the view here retainCount is 2?
This will cause a memory leak

view = [[UIView alloc] init];
self.myView = view ;/ / here plus self to prevent the release of the following view myView after pointing out the value of change.
[View release];
Reply:
self.view = [[UIView alloc] init ...] / / 1. using ARC mechanism, it does not cause the view here retainCount is 2, because this is just an initialization


self.view call the get method
The direct view is not through the get method

No comments:

Post a Comment