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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:32:49+00:00 2026-06-17T15:32:49+00:00

I have to add a source list (à la iTunes) to my Mac application.

  • 0

I have to add a source list (à la iTunes) to my Mac application. For that, I try the (SidebarDemo from Apple). It works fine. I added a button in this demo to demonstrate the effect of the reloadData method on NSOutlineView. And as you can see in the image there is a problem (on the left, before the reloadData call, and on the right, after the reloadData call). The badges disappear, icons change, etc.

What is the problem? Should I avoid using reloadData on NSOutlineView?

I’m using OS X 10.8.2, SDK 10.8 and Xcode 4.5.2.

You can download the modified SidebareDemo project here.

Thank you!

Before and after...

  • 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-17T15:32:51+00:00Added an answer on June 17, 2026 at 3:32 pm

    The SidebarDemo sample code makes the mistake of using the same object to represent multiple rows in the outline view. In particular, the underlying data used by the data source is created like so:

    _childrenDictionary = [NSMutableDictionary new];
    [_childrenDictionary setObject:[NSArray arrayWithObjects:@"ContentView1", @"ContentView2", @"ContentView3", nil] forKey:@"Favorites"];
    [_childrenDictionary setObject:[NSArray arrayWithObjects:@"ContentView1", @"ContentView2", @"ContentView3", nil] forKey:@"Content Views"];
    [_childrenDictionary setObject:[NSArray arrayWithObjects:@"ContentView2", nil] forKey:@"Mailboxes"];
    [_childrenDictionary setObject:[NSArray arrayWithObjects:@"ContentView1", @"ContentView1", @"ContentView1", @"ContentView1", @"ContentView2", nil] forKey:@"A Fourth Group"];
    

    NSString literals of identical value are uniqued by the compiler, so each occurrence of @"ContentView1" refers to the same object in memory. The result of this is that when the code inside -outlineView:viewForTableColumn:item: looks up the parent of the item to determine which icon or unread state to use, -[NSOutlineView parentForItem:] will only ever return a single parent for all of the @"ContentView1" items. The fact that it works at all in the initial case appears to be an accident in implementation. The order in which the calls to -outlineView:viewForTableColumn:item: are made is slightly different during the initial load vs the reload.

    The solution would be to use unique objects to represent each item in the outline view. The most trivial modification to the SidebarDemo sample that achieves this is to create a mutable copy of each NSString value before storing it in _childrenDictionary:

    _childrenDictionary = [NSMutableDictionary new];
    [_childrenDictionary setObject:[NSArray arrayWithObjects:[@"ContentView1" mutableCopy], [@"ContentView2" mutableCopy], [@"ContentView3" mutableCopy], nil] forKey:@"Favorites"];
    [_childrenDictionary setObject:[NSArray arrayWithObjects:[@"ContentView1" mutableCopy], [@"ContentView2" mutableCopy], [@"ContentView3" mutableCopy], nil] forKey:@"Content Views"];
    [_childrenDictionary setObject:[NSArray arrayWithObjects:[@"ContentView2" mutableCopy], nil] forKey:@"Mailboxes"];
    [_childrenDictionary setObject:[NSArray arrayWithObjects:[@"ContentView1" mutableCopy], [@"ContentView1" mutableCopy], [@"ContentView1" mutableCopy], [@"ContentView1" mutableCopy], [@"ContentView2" mutableCopy], nil] forKey:@"A Fourth Group"];
    

    In real-world code you’re unlikely to be bitten by this problem since your underlying data objects would be composed of instances of your model classes,, rather than consisting only of string literals.

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

Sidebar

Related Questions

In my application, like many Mac applications, I have a source list. At the
I have an add this button on the website that is rendering a border
I have to add a textbox inside a form that is composed of a
I have a list of links that all go to a google maps api.
Background I am creating a Source List for my application and I want it
I have my source list data in the sourceList data table and want to
I'm having two sortable lists where I can add items from the first list
Greetings. I have an RDLC file and am wanting to add a data source
I have this CMakeLists.txt file, I try to add clutter-gtk but I can't, it's
I am trying to create a data validation list whose source comes from a

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.