(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 toBundle
.- The
init(forClass:)
initializer ofBundle
has been renamed toinit(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))
// ...
}
}