IIRC this isn’t possible because there’s no Runtime to query for classnames 
(it’s inherently unsafe anyway).

You might want to look into a better way of doing that you’re trying to do.

— Harlan

> On Dec 10, 2015, at 12:42 AM, Matthew Davies via swift-users 
> <[email protected]> wrote:
> 
> I am using the Swift build tool & package manager. I'm trying to figure out 
> how to instantiate a class from a string. For instance, in PHP I can do:
> 
> $instance = new $className
> 
> I can (in the iOS & OS X runtimes) use "NSClassFromString", but this is 
> unavailable in the Swift build tool. How can I (or can I?) get the same 
> functionality?
> 
> 
> 
> Matthew Davies
> Junior Developer, GeoStrategies <http://geostrategies.com/>
> Director of Photography, OffBlock Films <http://offblockfilms.com/>
> 209-225-3246 <tel:209-225.3246> | 209-202-3284 <tel:209-202-3284> | 
> [email protected] <mailto:[email protected]> | daviesgeek.com 
> <https://daviesgeek.com/>
>  <http://facebook.com/daviesgeek>  <http://us.linkedin.com/in/daviesgeek>  
> <http://twitter.com/daviesgeek>  <http://daviesgeek.com/feed.xml>   
> <http://github.com/daviesgeek>
> 
>  _______________________________________________
> swift-users mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to