Skip to content

Instantly share code, notes, and snippets.

@uberto
Created June 24, 2014 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uberto/ec9af96637c1910718d2 to your computer and use it in GitHub Desktop.
Save uberto/ec9af96637c1910718d2 to your computer and use it in GitHub Desktop.
Magic dynamicity in Swift for legacy objects
class Foo: NSObject{ func foo() -> String{return "foo"}}
class Bar {func bar() -> String{return "bar"}}
let b: AnyObject = Bar()
//fail b.bar()
let f: AnyObject = Foo()
f.foo() //it works!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment