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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:44:03+00:00 2026-06-18T02:44:03+00:00

How do I set the array in my model-class ValueItem with the content of

  • 0

How do I set the array in my model-class ValueItem with the content of an NSArrayControllerin my AppDelegate class:

@interface AppDelegate : NSObject <NSApplicationDelegate>
{
    ValueItem *vi;
}

and:

@implementation AppDelegate
{

    ValueItem *array = [[ValueItem alloc]init];
    [array setValueArray:[outArrayController arrangedObjects]];

    NSArray *testArray2 = vi.valueArray; // !!!getter or setter doesn't work!!!
    NSLog(@"test array 2 is:%@", testArray2);
}

NSLog returns NULL. What do I miss here?
(valueArray is initialized with @property and @synthesize)

ValueItem.h:

#import <Foundation/Foundation.h>
@interface ValueItem : NSObject
{
    NSNumber *nomValue;
    NSNumber *tolerancePlus;
    NSNumber *toleranceMinus;
    NSMutableArray *valueArray;
}
@property (readwrite, copy) NSNumber *nomValue;
@property (readwrite, copy) NSNumber *tolerancePlus;
@property (readwrite, copy) NSNumber *toleranceMinus;
@property (nonatomic, retain) NSMutableArray *valueArray;

@end

ValueItem.m:

#import "ValueItem.h"
@implementation ValueItem

@synthesize nomValue, tolerancePlus, toleranceMinus;
@synthesize valueArray;

-(NSString*)description
{
    return [NSString stringWithFormat:@"nomValue is: %@ | tolerancePlus is: %@ | toleranceMinus is: %@", nomValue, tolerancePlus, toleranceMinus];

}
@end
  • 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-06-18T02:44:04+00:00Added an answer on June 18, 2026 at 2:44 am

    Solution: Need to make sure you’re dealing with the AppDelegate’s vi property:

    // We need to make sure we're manipulating the AppDelegate's vi property!
    self.vi = [[ValueItem alloc]init];
    [vi setValueArray:[outArrayController arrangedObjects]];
    
    NSArray *testArray2 = vi.valueArray; // !!!getter or setter doesn't work!!!
    NSLog(@"test array 2 is:%@", testArray2);
    

    Explanation :
    On the first two lines you were manipulating the array ValueItem variable, then attempting to set testArray2 to the value of the uninitialized vi ValueItem variable.

    // This is a new variable, unrelated to AppDelegate.vi
    ValueItem *array = [[ValueItem alloc]init];
    [array setValueArray:[outArrayController arrangedObjects]];
    
    // Here, AppDelegate.vi hasn't been initialized, so valueArray *will* be null!
    NSArray *testArray2 = vi.valueArray; 
    NSLog(@"test array 2 is:%@", testArray2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of integers in my core data model. It is set
I've got an array with data from a MySQL table in nested set model
How to call array from the model-class in my NSWindowController ? The valueArray is
The following are some of my coffeescript code class Floor extends Backbone.Model defaults: array:[]
I have an Model Class. When I call a the method setter, I set
I have a model public class Foo{ public int Id{get;set;} public string Name {get;
Hello I'm working on a problem that requires me to change an set array
I normally save new data to the database like this: $this->MyTable->set(array( 'id' => $id,
I have set an array in my config file that I use global in
I have an array set inside a velocity template that contains some paths. The

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.