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

Re: Only assign value to variable if not nil.


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

Bingo.  Ternary operators.

Thanks all.

On Jan 6, 2016, at 5:45 PM, Alex Zavatone wrote:

> 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


_______________________________________________

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


References: 
 >Only assign value to variable if not nil. (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Only assign value to variable if not nil.
  • Next by Date: Re: More Xcode 7 inconsistency?
  • Previous by thread: Only assign value to variable if not nil.
  • Next by thread: Re: More Xcode 7 inconsistency?
  • Index(es):
    • Date
    • Thread