Swift 3 Bundle example (for: XXX)

I am making a Swift 3 module. Therefore, I need to know the package associated with the class in this module. In Swift 2, it was:

let bundle = NSBundle(forClass: self.dynamicType)

How do I do this in Swift 3?

enter image description here

+4
source share
2 answers

Decision:

let bundle = Bundle(for: type(of: self))
+9
source

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

-1
source

Source: https://habr.com/ru/post/1654516/


All Articles