iCloud loses NSData

265 Views Asked by At

I'm creating an app with iCloud. But I have some problems.
It creates directory on iCloud using NSFileWrapper, then it creates NSData (text) file in NSFileWrapper directory.
I'm using this code to convert NSData to NSString:

text=[NSString stringWithUTF8String:[fileData bytes]];

And it works correctly only on the device, which creates this text file. On other devices file is loaded successfully, but when I try to convert or print it (or other call methods), result is **BAD_ACCESS** and object doesn't exist (retain count of file data is 2).

Any ideas?

1

There are 1 best solutions below

1
On

I think you should be converting it to a string like this:

NSString *string = [[NSString alloc] initWithData:[fileData bytes] encoding:NSUTF8Encoding];