ios - Get file path from a NSBundle which is not the mainBundle -


i'm trying pathforresource plist file, when file in mainbundle easy, used:

let path = nsbundle.mainbundle().pathforresource("settings", oftype: "plist")

but moved settings file bundle , don't know how it. tried use forclass , allbundles i'm swift rookie , didn't managed make work. coulden't find solution on web. seems nsbundle usages examples mainbundle

if don't know bundle has resource loop through of them:

let bundles = nsbundle.allbundles()  var path : string? var mybundle : nsbundle?  bundle in bundles {     if let resourcepath = (bundle as! nsbundle).pathforresource("settings", oftype: "plist") {         path = resourcepath         mybundle = bundle         break     } } 

on other hand, if have path or identifier of bundle use:

let bundle = nsbundle(path: "the-bundle-path")  or  let bundle = nsbundle(identifier: "bundle-identifier") 

this has nothing level of swift programming knowledge, rather interface nsbundle exposes. should check docs out see if can you.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -