• 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
Only assign value to variable if not nil.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Only assign value to variable if not nil.


  • Subject: Only assign value to variable if not nil.
  • From: Alex Zavatone <email@hidden>
  • Date: Wed, 06 Jan 2016 17:45:35 -0500

Hi all.  I was just extending some of my configuration file support on iOS to add move from one config file to one master and then a product specific one.

So, in the master, i'll have the full set of changeable properties defined in a pList and after reading this into a dictionary, I'll assign them to the various properties one at a time.

Of course, the product specific config file will supply any values we'd wish to overwrite, but not the whole set of options that are in the master.

In this, I'm currently assigning the property value based on the result returned from calling objectForKey: on the config dictionary.

Without resorting to if/then/elsing the code to death, is there a way to accomplish assigning a value to a variable only if the value is not nil?

Or am I thinking about this issue all bass ackwards.

Yeah, I could use placeholders before assigning, but I'm figuring there's something I could learn here and one of you just might know what that is.

Cheers,
Alex Zavatone




_______________________________________________

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: Only assign value to variable if not nil.
      • From: Alex Zavatone <email@hidden>
  • Prev by Date: Re: making a pronunciation dictionary for Voiceover on the iphone
  • Next by Date: Re: Only assign value to variable if not nil.
  • Previous by thread: Re: making a pronunciation dictionary for Voiceover on the iphone
  • Next by thread: Re: Only assign value to variable if not nil.
  • Index(es):
    • Date
    • Thread