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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:25:40+00:00 2026-05-22T19:25:40+00:00

I am trying to setup an NSCollectionView that has custom drawing in the individual

  • 0

I am trying to setup an NSCollectionView that has custom drawing in the individual NSCollectionViewItem views. I have an image that I need to draw in each view, but I cannot link the view back to the NSCollectionViewItem subclass in Interface Builder. Is there an init method I can use with my NSCollectionViewItem in order to perform initialization operations? I tried to implement copyWithZone, but I was doing something wrong because I got some eternal loop. Currently, the only opportunity I have found to make my connections to the view are after the selection has changed using -(void)setSelected:(BOOL)flag. I want to do my drawing in the view, but I need an image from my representedObject as my source. Everything I read that is NSCollectionView related, is seemingly incomplete.

@implementation CollectionViewItem
    -(void)setSelected:(BOOL)flag {
        [super setSelected:flag];
        NSLog(@"setSelected: %d", flag);
        // tell the view that it has been selected
        [(CollectionViewItemView* )[self view] setSelected:flag];
        // This is where I pass my image to my view
        [(CollectionViewItemView* )[self view] setOriginalSprite:[(MyModel* )self.representedObject imageSource]];
        [(CollectionViewItemView* )[self view] setNeedsDisplay:YES];
    }
@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-05-22T19:25:40+00:00Added an answer on May 22, 2026 at 7:25 pm

    I found this documentation – NSCollectionViewItem class

    What I found there shows setting a reference like so:

    Setting the Represented Object
    
        – representedObject Available in Mac OS X v10.5 through Mac OS X v10.5
        – setRepresentedObject: Available in Mac OS X v10.5 through Mac OS X v10.5 
    

    Your sample:
    -(void)setSelected:(BOOL)flag

    I don’t know the language but is BOOL an id?

    setRepresentedObject:

    Sets the receiver’s represented object
    to the specified model object.
    (Available in Mac OS X v10.5 through
    Mac OS X v10.5.)
    – (void)setRepresentedObject:(id)object
    Parameters

    object

    The receiver’s model object.
    

    Availability

    Available in Mac OS X v10.5 through Mac OS X v10.5.
    

    Declared In NSCollectionView.h

    Note: I did see this on the documentation:

    Important: In Mac OS X v10.5, the superclass of the NSCollectionViewItem class was NSObject. In Mac OS X v10.6 and later, NSCollectionViewItem is now a subclass of NSViewController. This change was made to improve how the view is replicated within the NSCollectionView. NSCollectionViewItem remains binary compatible with the previous implementation and unarchiving is correctly handled.

    So, if you are used to working with an older API, there may have been some changes since you last did this …???

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

Sidebar

Related Questions

I am trying to setup an activity in Android that has 50% of the
Trying to setup a windows development machine for a Rails project that has a
Im trying to setup my asp.net mvc page like the following image: The header
I'm trying to setup a private beta for a site that I'm working on.
I'm trying to setup some friendly URLs on a SharePoint website. I know that
I'm trying setup a map that displays different pin colors depending on the type/class
I'm trying to setup a simple has_many :through => association. I have 3 models.
I'm trying to setup a loop in Wordpress that will show all posts from
I'm trying to set up an NSCollectionView (I have done this successfully in the
Trying to setup a simple Thread/Poll table mapping. Here is what I have: Threads

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.