Re: Only assign value to variable if not nil.
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