Failed to read file, error Error Domain=NSCocoaErrorDomain Code=260

1,417 views
Skip to first unread message

torsten...@googlemail.com

unread,
Oct 28, 2016, 3:19:58 AM10/28/16
to CodenameOne Discussions
IDE: Eclipse
Desktop OS : WIndows
Device  iOS 7 and higher


Good morning,

I have a huge problem with my iOS App.
After a few month I've done a change and build the app new with codename one.
The android app works fine but the iOS app crashes directly after start.

The problem has nothing to do with my changes. I've only changes some visibility stuff.
The app runs a background service which is developed as native code for android and iOS.

In the app I save some internal information with

Storage.getInstance().writeObject("mobile.ID", "123");

In the past it was no problem to read this data in the native iOS code with

NSData *data=[NSData dataWithContentsOfFile:storagePathForName(filename) options: 0 error: &error];

where filename = "com.timeentry/mobile.ID"

Now I've got the error message

Oct 28 08:54:07 myPhone TimeEntry[183] <Warning>: Failed to read file, error Error Domain=NSCocoaErrorDomain Code=260 "The operation couldn’t be completed. (Cocoa error 260.)" UserInfo=0x15c136f0
{NSFilePath=/var/mobile/Applications/F17C0AE9-4AB3-4496-8B67-36F39EE6DE47/Library/Caches/com.timeentry/mobile.ID, NSUnderlyingError=0x15c14ee0 "The operation couldn’t be completed. No such file or directory"}

An output at start of the app shows as full path of the file

/var/mobile/Applications/F17C0AE9-4AB3-4496-8B67-36F39EE6DE47/Library/Caches/com.timeentry/mobile.ID

It's completely the same as the path where the background service is looking for the file.

Do you have any ideas or explanations for me ?

best regards,
Torsten

Shai Almog

unread,
Oct 28, 2016, 10:20:09 PM10/28/16
to CodenameOne Discussions, torsten...@googlemail.com
Hi,
you seem to access the caches directory instead of the documents directory I'm not sure how that worked for you.

torsten...@googlemail.com

unread,
Oct 31, 2016, 4:47:28 AM10/31/16
to CodenameOne Discussions, torsten...@googlemail.com
Hi,

sounds logicaly, but it works in the past.
How can I arrange that Storage.getInstance().writeObject("mobile.ID", "123") writes to the documents directory ?

It must be possible to read the data stored with Storage.getInstance().writeObject("mobile.ID", "123") in the
native iOS code. Isn't it ?

best regards,
Torsten

torsten...@googlemail.com

unread,
Oct 31, 2016, 9:21:17 AM10/31/16
to CodenameOne Discussions, torsten...@googlemail.com
Hi,

I've solved the problem.
The last build of the app is older than I thought.

The first problem was

https://www.codenameone.com/blog/storage-migration.html

Now I've added the build argument ios.newStorageLocation .
The paths now links to the document directory of the app.

The second problem was the subdirectory. All storage data will be saved in the
subdirectory "cn1storage" .

Now it works fine again.

Thanks and best regards,

Torsten





On Saturday, October 29, 2016 at 4:20:09 AM UTC+2, Shai Almog wrote:

susan.br...@gmail.com

unread,
Apr 11, 2018, 10:34:23 AM4/11/18
to CodenameOne Discussions
I’m receiving this code on my iPad when trying to save photos from Gmail... I’m a novice, a wanna-sit-n-drive, user of technology... so how can I fix this error? I also recently completed a software update...
Thanks!

Shai Almog

unread,
Apr 12, 2018, 1:37:04 AM4/12/18
to CodenameOne Discussions
Hi,
I doubt that's what you are getting.
I suggest you open a new thread with full details of the issue you are experiencing with device/OS version and what you did in the code.
Also the full text of the error (and where you saw it) would help.
Reply all
Reply to author
Forward
0 new messages