Note that there are some explanatory texts on larger screens.

plurals
  1. PONSCollectionView draws nothing
    primarykey
    data
    text
    <p>I'm trying to set up an <code>NSCollectionView</code> (I have done this successfully in the past, but for some reason it fails this time).</p> <p>I have a model class called "TestModel", and it has an <code>NSString</code> property that just returns a string (just for testing purposes right now). I then have an <code>NSMutableArray</code> property declaration in my main app delegate class, and to this array I add instances of the <code>TestModel</code> object.</p> <p>I then have an Array Controller that has its Content Array bound the app delegate's <code>NSMutableArray</code>. I can confirm that everything up to here is working fine; NSLogging:</p> <pre><code>[[[arrayController arrangedObjects] objectAtIndex:0] teststring] </code></pre> <p>worked fine.</p> <p>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 <code>Item.representedObject.teststring</code>. However NOTHING displays in the collection view when I start the app, just a blank white screen. What am I missing?</p> <p><strong>UPDATE: Here is the code I use (requested by wil shipley):</strong></p> <pre><code>// 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 </code></pre> <p>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.</p> <p><strong>UPDATE 2: If I log [collectionView content] I get nothing:</strong></p> <pre><code>2009-10-21 08:02:42.385 CollViewTest[743:a0f] ( ) </code></pre> <p>The problem is probably there.</p> <p><strong>UPDATE 3: As requested here is the Xcode project:</strong></p> <p><a href="http://www.mediafire.com/?mjgdzgjjfzw" rel="noreferrer">http://www.mediafire.com/?mjgdzgjjfzw</a></p> <p>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.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload