Get class of object in Swift 2.3


(Nate Birkholz) #1

self.dynamicType doesn't work any more, but type(of: self) is just Swift
3.0 So how do i get the class?

Use case in a unit test:

let bundle = NSBundle(forClass: type(of: self))

···

--
Nate Birkholz


(Nate Birkholz) #2

Never mind, .dynamicType works, it just doesn't autocomplete any more.
/facepalm

···

On Thu, Nov 10, 2016 at 11:54 AM, Nate Birkholz <nbirkholz@gmail.com> wrote:

self.dynamicType doesn't work any more, but type(of: self) is just Swift
3.0 So how do i get the class?

Use case in a unit test:

let bundle = NSBundle(forClass: type(of: self))

--
Nate Birkholz

--
Nate Birkholz