• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Is it safe to assume that viewDidLoad() is only ever called once on iOS 8.0+?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it safe to assume that viewDidLoad() is only ever called once on iOS 8.0+?


  • Subject: Re: Is it safe to assume that viewDidLoad() is only ever called once on iOS 8.0+?
  • From: Alex Zavatone <email@hidden>
  • Date: Sun, 18 Dec 2016 10:01:12 -0600

Allocate them in viewWillAppear: if they are nil.

Just create a  conditionalInit method for the purpose of this and put it inside viewWillAppear.

On Dec 18, 2016, at 4:51 AM, Andreas Falkenhahn wrote:

> I do not use Interface Builder or Storyboards to create my GUI
> but I do it manually. Currently, I'm setting up all controls
> in viewDidLoad() of my UIViewController.
>
> So I'm doing stuff like this in viewDidLoad():
>
>    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
>    ...
>    [self.view addSubview:button];
>
> The actual positioning is then done in viewDidLayoutSubviews(),
> depending on the device's orientation.
>
> According to my research, iOS versions before v6 purged views
> on low-memory conditions but AFAIU this is no longer done starting
> with v6. My app targets iOS 8.0 and up so can I rely on viewDidLoad()
> being called only once?
>
> The reason why I'm asking is that I retain some controls in
> viewDidLoad() because I need them later. I release those controls
> in dealloc(). Now, if viewDidLoad() could be called more than
> once, I'd leak memory. But since viewDidUnload() is deprecated
> anyway, I think it is safe to assume viewDidLoad() is only called
> once because otherwise Apple would have to provide viewDidUnload()
> as well... but still, I'd be glad if somebody could just confirm
> my observations. Thanks.
>
> --
> Best regards,
> Andreas Falkenhahn                          mailto:email@hidden
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Is it safe to assume that viewDidLoad() is only ever called once on iOS 8.0+?
      • From: Andreas Falkenhahn <email@hidden>
References: 
 >Is it safe to assume that viewDidLoad() is only ever called once on iOS 8.0+? (From: Andreas Falkenhahn <email@hidden>)

  • Prev by Date: Re: Checkbox Mayhem
  • Next by Date: Re: Is it safe to assume that viewDidLoad() is only ever called once on iOS 8.0+?
  • Previous by thread: Is it safe to assume that viewDidLoad() is only ever called once on iOS 8.0+?
  • Next by thread: Re: Is it safe to assume that viewDidLoad() is only ever called once on iOS 8.0+?
  • Index(es):
    • Date
    • Thread