.dynamicType is deprecated. Use ‘type(of …)’ instead

(The below holds for Swift 3; not legacy Swift Language Version (2.3), however, so it doesn’t answer the OP’s question, but could be valuable for Swift 3 users, nonetheless)

As noted in your question, dynamicType is now (Swift 3) deprecated in favour of type(of:). In addition:

  • NSBundle has been renamed to Bundle.
  • The init(forClass:) initializer of Bundle has been renamed to init(for:).

Taking these changes into account, For Swift 3 you initialize (or fetch an existing instance associated with the specific class) your Bundle object in the following manner:

class Foo {
    func bar() -> () {
        let bundle = Bundle(for: type(of: self))
        // ...
    }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)