0

I realize similar questions have been asked before, most of them are for outdated version of ios and do not completely answer the changed aspects from the version.

What types of objects should we set up in these methods in a viewcontroller to get the best performance?

I would like a detailed answer like:
Declaring int variables at x is good because y and so on.
I would like an explanation for NSString, NSInteger, UIImage, UI elements, graphics, network calls, coredata calls.

What kind of objects are we encouraged to get rid of at viewwilldisappear?

If all these are stated together in a complete answer, it would be useful for everybody.

Edit:
Difference between viewDidLoad and viewDidAppear
Bad question Answer good but does not include initiliaze and viewdiddisappear

init method vs. a viewDidLoad type method
Question and answer left out viewdidappear and disappear

iOS: What is the difference between -init and -viewLoad of a ViewController?
Outdated, uses nibs.

iPhone dev - create array in init or viewDidLoad
I do not agree with the answer, something probably changed from 2009.

Community
  • 1
  • 1
Esqarrouth
  • 38,543
  • 21
  • 161
  • 168
  • 3
    You should read a book, what you're asking requires a huge answer! – Merlevede Feb 17 '14 at 07:55
  • guess you are right :) – Esqarrouth Feb 17 '14 at 07:56
  • 2
    I've voted to close as too broad a question - but I haven't changed the way I use these methods when moving from iOS 6 to iOS 7 and as far as I know the way these are used has changed. All you need to do really is read the Apple Docs https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW18 and that should explain it all. – Popeye Feb 17 '14 at 08:18
  • Thanks, I know I could learn by reading from there, I just wanted this community to have a decent question covering the whole topic, cause the other question and answers weren't good enough. – Esqarrouth Feb 17 '14 at 08:22
  • 1
    I don't believe these methods change a lot if they change at all so those question will still be informative. – Popeye Feb 17 '14 at 08:33
  • well ios6 was from last year. most of the relevant seeming posts about this are from 2010-2011. thats like ios3-5 i think. most still have autorelease in them. plus their qualities weren't as I expected either. – Esqarrouth Feb 17 '14 at 08:40
  • 2
    Nothing has rely changed. To get your point across and which would make it less broad I would recommend including 1 or 2 of these likes and saying why you think they have changed and then ask your question. – Popeye Feb 17 '14 at 08:43

1 Answers1

1

Init:

Instantiate any objects that you class will use. Do not add them to the view if they are to be subviews you must do this in viewDidLoad after the view has loaded.

ViewDidLoad:

At this point all you views have been instantiated so you can make any modifications, add subviews etc.

viewDidAppear:

Means what it says. If you want to change a background picture ever 5 seconds, I would start the timer here as you know the view is being seen by the user.

ViewDidDisappear:

The view is not currently being displayed -- so tidy up anything you don't need.

There are lots of other posts that have more detail if you search.

Link to Apple Doc (the first point of call)

geminiCoder
  • 2,918
  • 2
  • 29
  • 50