Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6928265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:09:50+00:00 2026-05-27T11:09:50+00:00

I have developed a small app that stores locally in iOS through archiving an

  • 0

I have developed a small app that stores locally in iOS through archiving an array of custom objects containing:

@property (nonatomic, copy) NSString    *name;
@property (nonatomic, copy) NSString    *dateCreated;
@property (nonatomic, copy) NSString    *desc;
@property (nonatomic, copy) NSString    *url;

I want to sync said archive using iCloud and I believe the recommended mechanism is through a UIDocument subclass.
All UIDocument examples I found utlilized a single instance with 1 single NSString, so I am a little confused how to go about syncing a whole array of custom objects but utilizing UIDocument (like I do today locally through NSCoding).

Should I create an array of UIDocument objects containing the properties listed above, should I create an instance of UIDocument containing 1 instance of the data object described above and then create an array containing all the instances, or should 1 single UIDocument contain the complete array of custom objects ?

I have done some research but I am still confused.
In the end I would need to sync just 1 file containing an array of said custom objects.

Thanks in advance for your help

What I have today is a custom class as described above with 4 strings called Snippet and in my Root view Controller I have an NSMutableArray called list where I add each new instance of that Snippet Class.

self.list = [[NSMutableArray alloc] init];
Snippet *newEntry = [[Snippet alloc] init];
[self.list addObject:newEntry];

Should I create an UI Document subclass that owns the array of custom objects ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:09:51+00:00Added an answer on May 27, 2026 at 11:09 am

    The example in the docs does indeed show a UIDocument subclass that just has one string, but it returns a NSData from -contentsForType:error:. You can store as many objects as you like in an NSData using an NSKeyedArchiver. Read Serializing Objects to learn how to encode objects using NSKeyedArchiver (and keep reading to learn how to get them back!).

    Using your properties as an example…

    @interface MyDocument : UIDocument
    {
    }
    @property (nonatomic, copy) NSString    *name;
    @property (nonatomic, copy) NSString    *dateCreated;
    @property (nonatomic, copy) NSString    *desc;
    @property (nonatomic, copy) NSString    *url;
    @end
    
    @implementation MyDocument
    
    //...
    
    - (id)contentsForType:(NSString *)typeName error:(NSError **)outError
    {
        NSMutableData *data = [NSMutableData data];
        NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
        [archiver encodeObject:name forKey:@"name"];
        [archiver encodeObject:dateCreated forKey:@"created"];
        [archiver encodeObject:desc forKey:@"desc"];
        [archiver encodeObject:url forKey:@"url"];
        [archiver finishEncoding];
        // release archiver if you're not using ARC
        return data;
    }
    @end;
    

    WARNING: I haven’t compiled the code above, so no guarantees. This should serve as an example to illustrate using an archiver to store multiple objects in a single data object which you can return as your document’s content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a small download system in PHP, where files are downloaded through
I have developed a small view that contains special char like 'é' and when
Hey guys, I have developed a small site that i would like to embed
I have developed a small web app. This app allows users to upload images.
I have a small Android app developed in Eclipse on Windows and versioned on
I have a developed a small web-app in Symfony 2 and Doctrine 2. Can
I have a small app I've made that I intend to make available on
I have a small Sinatra application that is calling a library I developed named
I'm using BerkeleyDB to develop a small app. And I have a question about
I have developed a small application and now i want to protect it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.