NSBundle.mainBundle().pathForResource()
why not enter in section of if?
Asked
Active
Viewed 222 times
-2
-
2Do not post an image of your code. Copy and paste the actual code into your question (and be sure you format it properly). – rmaddy Apr 22 '16 at 00:52
-
1And why all of the breakpoints? Use only the 1st one and then single step if you wish to stop at each line. – rmaddy Apr 22 '16 at 00:53
1 Answers
2
The argument to the ofType
parameter of the pathForResource
function needs to be a filename extension, not a mime-type. So you probably just want "xml"
, not "text/xml"
.

rmaddy
- 314,917
- 42
- 532
- 579
-
NSBundle.mainBundle().pathForResource("MARIO.xml", ofType: nil)) , NSBundle.mainBundle().pathForResource("MARIO", ofType: "xml")) NSBundle.mainBundle().pathForResource("MARIO.xml", ofType: "text/xml")) NSBundle.mainBundle().pathForResource("MARIO", ofType: "text/xml")) ALL NOT WORK – Isa M Apr 22 '16 at 06:07
-
Then you don't actually have a file named `MARIO.xml` in your app's resource bundle. – rmaddy Apr 22 '16 at 14:03
-
///private/var/mobile/Containers/Data/Application/...../Documents/MARIO.xml --- archivo:: /// archivo privado / var / mobile / Contenedores / datos / aplicaciones / ..... ... / Documentos / archivo MARIO2.xml:--- ///private/var/mobile/Containers/Data/Application/...../Documents/SingleViewCoreData.sqlite archivo: /// privado / var / mobile / Contenedores / Los datos / documentos / aplicación /...../ SingleViewCoreData.sqlite-SHM archivo:---///private/var/mobile/Containers/Data/Application/.../Documents/fuck.xml-- This is what I have in my Directory – Isa M Apr 22 '16 at 14:44
-
I'm not sure what that mess is supposed to be but I still don't see a `MARIO.xml` file in your app bundle. I see one in the Documents folder though. But that's not the app's resource bundle. – rmaddy Apr 22 '16 at 14:47
-
 The file was created , I keep in Documents – Isa M Apr 22 '16 at 14:58