I have not clear how Objective C handle the local and member variable, as I am new to this.
Consider I am creating a view inside a function like this…
fun () {
new_class *var = [new_class alloc] init]
// some code to push the view here...
}
everything works fine here, now my question is var is a local variable, when the function scope ends, will it die or not? if it dies how the view is working properly when I am doing some action in it…
thanks…
The var should be release, if it doesn’t have other objects point at it. The thing is:
If your “var” is an
UIViewfor instance, and you[self.view addSubview:var], now you have two objects pointing at it:*varand yourself.view, that’s why everything is ok.