<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 6, 2016, at 9:39 PM, Michael Sheaver via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I know that in some languages, if you prepend the passed parameter with a '$', as in $propertyName, the receiving function knows to use the<span class="Apple-converted-space">&nbsp;</span><u class="">contents</u><span class="Apple-converted-space">&nbsp;</span>of the variable named propertyName (in this case "calendar") instead of the literal string "propertyName".&nbsp;</div></div></blockquote></div><br class=""><div class="">No, you can’t do that. The languages I think you’re referring to — PHP, Perl — are interpreted scripting languages. Very different beasts, where everything is dynamic and looked up at runtime. (Generally all objects are implemented as dictionaries with property names as keys, making it easy to look up properties by name.) Swift is more like C or C++.</div><div class=""><br class=""></div><div class="">Now, Objective-C has a fairly dynamic runtime that allows you to do this. Objects have a method valueForKey that takes a string and finds a property of the object with that name and returns its value. You can do this in Swift (on Apple platforms) if the class inherits from NSObject or has the @objc attribute. But this isn’t “pure” Swift; it’s an Objective-C feature you’re accessing through bridging.</div><div class=""><br class=""></div><div class="">Generally, there are other patterns that are used to get this sort of effect in languages that aren’t so dynamic (like C++ for example.) But we’d need to know more about the higher-level problem you’re trying to solve, to give advice on that.</div><div class=""><br class=""></div><div class="">—Jens</div></body></html>