Allow Swift code to dynamically create and use names for classes and functions
| Originator: | |||
| Number: | rdar://17318591 | Date Originated: | 2014-06-15 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6 beta 1 |
| Classification: | Feature Request | Reproducible: |
Currently Swift lets you create variables having the Selector type, which is really just a string, but you cannot do anything with it from within Swift. Specifically, I'm looking to do the following: var f = "myFunctionName" f() // call the function named myFunctionName var c = "myClassName" var instance = c() // create an instance of class myClassName var p = "myPropertyName" c.p // access the property called myPropertyName This allows the code to read the name of the class or function from a database table, for example, and determine at runtime which class to instantiate and/or function to call. Even PHP allows for this. ;-)
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!