ios - Save a NSArray to iCloud and retrieve it -
i have app saves nsmutablearray file in documents directory on ipad. saved
[residentdata writetofile:filepath atomically:no];
and read in by;
residentdata = [[nsmutablearray alloc] initwithcontentsoffile:filepath];
i need write file icloud, data needs available across several devices. have tried following create file in icloud;
nsdata *myfiledata = [nskeyedarchiver archiveddatawithrootobject:residentdata]; [filemanager createfileatpath:[icloudurl path] contents:myfiledata attributes:nil];
which indeed create file in correct place. struggling though understand how read file nsmutablearray (residentdata). have tried;
residentdata = [nskeyedunarchiver unarchiveobjectwithdata:myfiledata];
but doesn't decode array correctly. please can show me error of ways - suspect fundamental misunderstanding on part of nsdata blame, pointers welcome.
it clicked, approach wrong. don't need use of above. once have done the;
[filemanager setubiquitous:yes itematurl:currentplace destinationurl:icloudurl error:&error];
the system takes care of else - i.e. accessing file with
residentdata = [[nsmutablearray alloc] initwithcontentsofurl:icloudurl];
has worked.
Comments
Post a Comment