[SOLVED][iOS][Qt 5.2]QFile doesnt create new file
-
Hi,
I got a problem i cannot create new file on iPad. There is the code:
@QFile tf("abc.txt");
tf.open(QIODevice::ReadWrite);
tf.write("TEST");
tf.close();
if(QFile::exists("abc.txt"))
qDebug()<<"abc.txt exists";
else
qDebug()<<"abc.txt doesnt exists";@I keep getting abc.txt doesnt exists in debug console.
I have no idea why, the code works on linux, mac and android, so why doesnt it work on iOS.Thanks
EDIT: I forgot to mention I alse get this: "QIODevice::write: device not open"
I believe application doesnt have permission to write on iPad but what should i do to set it?
-
what does the following return?
@
qDebug() << QFile("abc.txt").exists();
@ -
Hi, kolegs.
It doesn't work due to Apple's sandbox policy.
You're able to write files only to 'Documents' and 'Caches' directories, but not to application's directory.This version works as well:
@ QString fileName = "../Documents/abc.txt";
QFile tf(fileName);
tf.open(QIODevice::ReadWrite);
tf.write("TEST");
tf.close();
if(QFile::exists(fileName))
qDebug()<<"abc.txt exists";
else
qDebug()<<"abc.txt doesnt exists";@Here is the link where you can read more about this feature:
https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AboutAppSandbox/AboutAppSandbox.html -
Thanks, that's so obvious but I am new to iOS and Mac.
-
Hi
it appears that this no longer works in IOS8,
it now reports:
QIODevice::write: device not open
abc.txt doesnt existsAny ideas about where we can open a file now
thank you
ed
-
check this out http://qt-project.org/forums/viewthread/47051/
-
Thank you
ed