Friday 15 January 2010

ios - How I could push to my own view without having to instance itself everytime I do it -


Im every time I press it, pointing to my own visual class.

MyOwnView * newSameView = [[MyOwnView alloc] initWithNibName: zero bundle: NULL]; [Self. Navigation controller Push ViewController: Animated MyOwnView: Yes];

You asked "But do I allocate it every time?" There is no answer. Whenever you create an event, it allocates different memory, but when you close the view controller with the stack, that memory is freed.

If you want to have an example of your MyOwnViewController class, then create a property "lazy load" a view controller, and use it

If this is your property: < / P>

  @property (nonatomic, strong) MyOwnViewController * myVC;  

The recipient will look something like this:

  - (MyOwnViewController *) myVC; {If (_myVC == zero) _myVC = [[MyOwnViewController alloc] initWithNibName: zero bundle: NULL]; Return _myVC; }  

Then you can write code that suppresses view controller in such a way:

  [self.navigationController pushViewController: self.myVC Animated: yes];  

The good thing about this is that you only make an example of your MyOwnViewController. The bottom side is that unless the view controller makes such a move it is never released, unless you explicitly set it to zero. If you do not need it at any point, then additional memory (again, unless you manually set the property to zero)

Another approach is every time a new copy of MyOwnViewController Makes it necessary, and after that it pops out, then it removes it. You do more to create / destroy MyOwnViewController instances, but they do not take memory when you do not use them.


No comments:

Post a Comment