0
votes

i have searched a lot also here on SO but i haven't find a way to start what i want, in my app i want to save some custom object on iCloud, i think the best way is using UIDocument, this is the custom Object:

@interface AppState : NSObject

@property (nonatomic, strong) NSNumber *timestamp;
@property (nonatomic, strong) NSNumber *type;
@property (nonatomic, strong) NSString *note;
@property (nonatomic, strong) NSString *device;

@end

then i doesn't know how, i want store this information on iCloud and retrieve it on the other device, i know i have to subclass the UIDocument class, but i can't figure out how i store this information, i have to insert it in an array? or something else? any help will be appreciate because i have find a lot of tutorial on how store nsstring, but i have a custom object, and i want also know if possible how this information is stored on iCloud, a single file for every Custom Object, or are all insert in one single file?

1

1 Answers

0
votes

First of all, you have to put it in a file (or files). Then, you'll have to write a method to read and write it to a file (or files). So the big decision is what format of file: You could just open a plain file and write the data in using delimiters, or you could open 4 files and write each data item in its own file. You could also get fancy and store it as serialized data using encoders, or you could even store it in a SQLite database. Or, you could show off your programming ability and store it in core data, though both the SQLite and CoreData solutions seem overkill for what you currently have. As long as you write the file to a directory that is shared by iCloud, it will be stored in iCloud. You can make sure that the "don't store this file to iCloud" bit is not set, but I think it comes set to store it on creation.

How you store your data is often dependent on how you want to use it. In this case, with such small amounts of data, I'd just write it out to a file, and use delimiters.