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 4618048
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:12:39+00:00 2026-05-22T02:12:39+00:00

I am having an issue where I am saving, among other things, an array

  • 0

I am having an issue where I am saving, among other things, an array of “nodes” (header below) that posses a color and a tag property. When it saves as in – (void)saveDataToDiskWithPath:(NSURL*)path, the log shows that these properties exist. When I load the array again at a later time from the saved file, the frame of the node persists, but each node in the array has lost its tag and color…any ideas why? What could I be doing wrong? Maybe I’m just tired, and it will all make sense later…

Node.h:

//
//  Node.h
//

#import <Cocoa/Cocoa.h>


@interface Node : NSView {
@private
    NSColor *thisColor;
    NSColor *originalColor;
    NSRect dragRect;
    BOOL msDn;
    long tag;
    BOOL amSelected;
}

@property long tag;
@property (nonatomic, retain) NSColor* originalColor;

- (id)initWithFrame:(NSRect)frame andColor:(NSColor*)color;
- (void)select:(BOOL)yesOrNo;

@end

The save method:

- (void) saveDataToDiskWithPath:(NSURL*)path
{
    NSLog(@"Path is %@", [path absoluteString]);
    NSMutableDictionary * rootObject;
    rootObject = [NSMutableDictionary dictionary];
    for(Node* node in [sharedValues nodes]){
        NSLog(@"Node has color %@ and tag %ld.", [node originalColor], [node tag]);
    }
    [rootObject setValue: [imageView aPath] forKey:@"path"];
    [rootObject setValue:[sharedValues nodes] forKey:@"nodes"];
    [NSKeyedArchiver archiveRootObject: rootObject toFile: [path path]];
}

The load method:

- (void)loadDataFromDiskWithPath:(NSURL*)path
{
    NSDictionary * rootObject;

    rootObject = [NSKeyedUnarchiver unarchiveObjectWithFile:[path path]];    
    [imageView setAPath:[rootObject valueForKey:@"path"]];
    [sharedValues setNodes:[rootObject valueForKey:@"nodes"]];
    [imageView setNeedsDisplay:YES];
}
  • 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-22T02:12:40+00:00Added an answer on May 22, 2026 at 2:12 am

    You will have to adopt the NSCoding protocol and implement -initWithCoder: and -encodeWithCoder: methods for the object to archive properly. Since Node is a subclass of UIView which adopts the protocol, some parts of it are being archived correctly. These are the properties of UIView and its parent classes. To ensure proper archiving, Node will have to implement the protocol too. Go through this doc for additional insight.

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

Sidebar

Related Questions

Having an issue here that I have tried everything I can think of but
I'm having an issue with a query that currently uses LEFT JOIN weblog_data AS
I'm having an issue with a standard ASP.NET page that has a TextBox and
I'm quite new with Core Data, and I'm having an issue that I don't
I'm having a strange issue that I've never encountered before. I have a partial
I'm having an issue here that is blowing my mind. It's a very simple
I am having an issue with my ASHX handler that is generating PDF. When
Having an issue with random individuals trying to access an intranet site with a
The issue I'm having is issue with is I'm trying to get the paintComponent
I'm having an issue with my regex. I want to capture <% some stuff

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.