开发者

How do I access the iPhone applications Documents folder using XMLVM

I have been trying for the past day or so to create a file into the iPhone applications documents directory. Usually if I was doing it in Objective-C I would use

NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

The reason that I need access to this directory is to save a plist file with some application settings (that shouldn't change when the app needs updating).

I have been storing the file in the normal .app directory, but from there I cannot overwrite the file when I attempt to save some new settings.

Here is the code I am using to delete the file

public static Boolean DeleteSettingsFile(){
File f = new File(settingsFile);
    if(f.exists())
        if(f.delete())
            return true;
   return false;
}

This does not work when trying to delete a file from NSBundle.mainBundle().bundlePath() folder

And I get the same result with this code

public static Boolean SaveSettingsFile(String s){

    File f = new File(settingsFile);

    try {
        if(f.createNewFile())
            if(NSData.dataWithBytes(s.getBytes()).writeTo开发者_Python百科File(settingsFile, true))
                return true;
    }
    catch (Exception e){
        System.err.println(e.getMessage());
    }
    return false;
}

This will create the file, but then once it is there I can only read its contents.

Any help would be appreciated


In the latest version of XMLVM use the following code:

Foundation.NSSearchPathForDirectoriesInDomains( NSSearchPathDirectory, NSSearchPathDomainMask, expandTilde);

The parameters are exactly the same as in Objective C.

Note that the objects NSSearchPathDirectory, NSSearchPathDomainMask (and others) also exist.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜