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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:53:02+00:00 2026-05-12T20:53:02+00:00

I’m trying to set up an NSCollectionView (I have done this successfully in the

  • 0

I’m trying to set up an NSCollectionView (I have done this successfully in the past, but for some reason it fails this time).

I have a model class called “TestModel”, and it has an NSString property that just returns a string (just for testing purposes right now). I then have an NSMutableArray property declaration in my main app delegate class, and to this array I add instances of the TestModel object.

I then have an Array Controller that has its Content Array bound the app delegate’s NSMutableArray. I can confirm that everything up to here is working fine; NSLogging:

[[[arrayController arrangedObjects] objectAtIndex:0] teststring]

worked fine.

I then have all the appropriate bindings for the collection view set up, (itemPrototype and content), and for the Collection View Item (view). I then have a text field in the collection item view that is bound to Collection View Item.representedObject.teststring. However NOTHING displays in the collection view when I start the app, just a blank white screen. What am I missing?

UPDATE: Here is the code I use (requested by wil shipley):

// App delegate class

@interface AppController : NSObject {

NSMutableArray *objectArray;
}
@property (readwrite, retain) NSMutableArray *objectArray;
@end

@implementation AppController
@synthesize objectArray;

- (id)init
{
    if (self = [super init]) {
    objectArray = [[NSMutableArray alloc] init];
    }
    return self;
}


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    TestModel *test = [[[TestModel alloc] initWithString:@"somerandomstring"] autorelease];
    if (test) [objectArray addObject:test];
}
@end

// The model class (TestModel)

@interface TestModel : NSObject {
NSString *teststring;
}
@property (readwrite, retain) NSString *teststring;
- (id)initWithString:(NSString*)customString;
@end

@implementation TestModel
@synthesize teststring;

- (id)initWithString:(NSString*)customString
{
    [self setTeststring:customString];
}

- (void)dealloc
{
    [teststring release];
}
@end

And then like I said the content array of the Array Controller is bound to this “objectArray”, and the Content of the NSCollectionView is bound to Array Controller.arrangedObjects. I can verify that the Array Controller has the objects in it by NSLogging [arrayController arrangedObjects], and it returns the correct object. Its just that nothing displays in the NSCollectionView.

UPDATE 2: If I log [collectionView content] I get nothing:

2009-10-21 08:02:42.385 CollViewTest[743:a0f] (
)

The problem is probably there.

UPDATE 3: As requested here is the Xcode project:

http://www.mediafire.com/?mjgdzgjjfzw

Its a menubar app, so it has no window. When you build and run the app you’ll see a menubar item that says “test”, this opens the view that contains the NSCollectionView.

Thanks

  • 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-12T20:53:03+00:00Added an answer on May 12, 2026 at 8:53 pm

    The problem is that your not correctly using KVC. There is two things you can do.

    Method 1: Simple but not so elegant

    1. Use the following code to add the object to the array

    [[self mutableArrayValueForKey:@”objectArray”] addObject:test];

    This isn’t so elegant as you have to specify the variable using a string value, so you will not get compiler warnings when spelt incorrectly.

    Method 2: Generate the KVO methods needed for the array “objectArray”.

    1. Select the property in your interface declaration
    2. Select Scripts (the script icon in the menubar) > Code > Place
      accessor decls on Clipboard
    3. Paste the declarations in the
      appropriate spot in your interface file
    4. Select Scripts > Code > Place
      accessor defs on Clipboard
    5. Paste the definitions in the
      appropriate spot in your implementation file

    You can then use a method that looks like

    [self insertObject:test inObjectArrayAtIndex:0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.