William Entriken
William Entriken

Reputation: 39323

Swift 3 example of Bundle(for: XXX)

I am making a Swift 3 module. So I need to know the bundle associated with a class in that module. In Swift 2 this was:

let bundle = NSBundle(forClass: self.dynamicType)

How do I appropriately do this in Swift 3?

enter image description here

Upvotes: 4

Views: 2225

Answers (2)

sanjayzed
sanjayzed

Reputation: 57

let file = Bundle.main.path(forResource: "filename", ofType: "filetype")

Upvotes: -1

William Entriken
William Entriken

Reputation: 39323

Solution:

let bundle = Bundle(for: type(of: self))

Upvotes: 9

Related Questions