Can someone test this on iOS?

94 views
Skip to first unread message

Xerosugar

unread,
Mar 13, 2014, 10:07:09 PM3/13/14
to haxe...@googlegroups.com

var lvls:Array<String> = new Array<String>();
var fileNames:Array<String> = FileSystem.readDirectory(Reg.levelFileDir);

for (fileName in fileNames) {
    lvls
.push(fileName);
}


This makes my app crash for me and I don't know why :( Also, I can't trace anything to the terminal and no errors are displayed before it crashes, anyone else with this problem?

Hugh

unread,
Mar 14, 2014, 1:02:34 AM3/14/14
to haxe...@googlegroups.com

You should put a "try / catch" around the readDirecory in case the directory does not exits.

If you compile with -debug and start from xcode, you should get a more informative crash.


Hugh

Xerosugar

unread,
Mar 14, 2014, 8:07:29 AM3/14/14
to haxe...@googlegroups.com
Hugh, do you mean I should first run 'lime build ios -debug' from the terminal and then something else from inside Xcode? You have to be bo specific, because I'm not used to debugging in Xcode :(

Btw, I'm trying to figure out how to get trace messages to show up in Xcode's debugger. I tried opening the console with Shift + Command + C, but nothing shows up. Any ideas?

Xerosugar

unread,
Mar 15, 2014, 5:02:41 PM3/15/14
to haxe...@googlegroups.com
I still have problems using the FileSystem class (iOS-target). Please share your wisdom with me if you can!
This crashes the application on iOS-target:


FileSystem.createDirectory("asd123");
trace
(FileSystem.exists("asd123") );


Xcode says: "Could not create directory:asd123" ... and then prints out the "call stack" (if that's what it's called).

Hugh

unread,
Mar 17, 2014, 12:19:52 AM3/17/14
to haxe...@googlegroups.com

Hi

Your app can only create files/directories in certain areas. The "createDirectory" call is throwing an exception, which is what you are seeing.  To avoid the hard crash, you should do:

try {


   
FileSystem.createDirectory("asd123");
}

catch(e:Dynamic) {

  trace
("Error : " + e );
}



But I think the solution to your problem is to start with one of the predefined directories, like:

nme.filesystem.File.applicationStorageDirectory

or

 nme.filesystem.File.documentsDirectory 


Hugh

Xerosugar

unread,
Mar 17, 2014, 6:58:56 AM3/17/14
to haxe...@googlegroups.com
I got some help on Twitter yesterday and was finally able to solve this - this was the answer:


If you're targeting iOS, it's the document folder you're interested in, if you need a place to save "user-generated content".
More info here:

Thanks for the help.
Reply all
Reply to author
Forward
0 new messages