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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:17:45+00:00 2026-06-14T04:17:45+00:00

I’m implementing a simple file browser (in an NSOutlineView ) and am hitting an

  • 0

I’m implementing a simple file browser (in an NSOutlineView) and am hitting an EXC_BAD_ACCESS when expanding my root node. My NSOutlineViewDataSource returns the children as follows:

- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
    if (!item) {
        // Root node
        return @"Files";
    }
    NSFileManager *manager = [NSFileManager defaultManager];

    NSError *error = nil;
    return [[manager contentsOfDirectoryAtPath:@"/" error:&error] objectAtIndex:index];
}

The NSString being returned from this method is being autoreleased, and when the AppKit code calls here:

- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
    NSString *identifier = [item isEqualToString:@"Files"] ? @"HeaderCell" : @"DataCell";
    NSTableCellView *cell = [outlineView makeViewWithIdentifier:identifier owner:self];
    cell.textField.stringValue = item;
    return cell;
}

The item is already gone. This is an Instruments screenshot of the item’s lifecycle:

Instruments Screenshot

I’m not sure what I’m doing wrong – I can’t explicitly retain anything (nor should I!) because ARC is enabled, but still the child item is being lost.

Edit: Stacktrace of the actual crash:

   0 CoreFoundation -[__NSCFString retain]
   1 Spark -[SPFileBrowserController outlineView:child:ofItem:] /Users/Craig/projects/Spark/Spark/SPFileBrowserController.m:29
   2 AppKit loadItemEntryLazyInfoIfNecessary
   3 AppKit -[NSOutlineView _rowEntryForChild:ofParent:requiredRowEntryLoadMask:]
   4 AppKit -[NSOutlineView _expandItemEntryChildren:atStartLevel:expandChildren:andInvalidate:]
   5 AppKit -[NSOutlineView _expandItemEntry:expandChildren:startLevel:]
   6 AppKit -[NSOutlineView _batchExpandItemsWithItemEntries:expandChildren:]
   7 AppKit -[NSOutlineView expandItem:expandChildren:]
   8 AppKit -[NSOutlineView _doUserExpandOrCollapseOfItem:isExpand:optionKeyWasDown:]
   9 AppKit -[NSOutlineView _outlineControlClicked:]
  10 AppKit -[NSApplication sendAction:to:from:]
  11 AppKit -[NSControl sendAction:to:]
  12 AppKit -[NSCell _sendActionFrom:]
  13 AppKit -[NSCell trackMouse:inRect:ofView:untilMouseUp:]
  14 AppKit -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:]
  15 AppKit -[NSControl mouseDown:]
  16 AppKit -[NSWindow sendEvent:]
  17 AppKit -[NSApplication sendEvent:]
  18 AppKit -[NSApplication run]
  19 AppKit NSApplicationMain
  20 libdyld.dylib start

Edit 2: Project now attached. Edit the return value of SPFileUtil childrenOfFolder: to use Option 2 to reproduce consistently. It always passes when using a single NSString, but always fails when using the NSFileManager contents.

https://www.dropbox.com/s/lqj5r5ndg0qusak/Spark.zip

The crash occurs right after expanding the root “Files” item.

  • 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-14T04:17:47+00:00Added an answer on June 14, 2026 at 4:17 am

    It’s probably a bit unsafe to provide the outline view contents directly from the filesystem, for example what happens if a file is added/removed from the filesystem? A better approach is for you to cache the filesystem contents and provide contents directly from that. You can then be sure that the value returned from:

    – numberOfRowsInTableView:
    

    Matches the contents you have stored (and you don’t get out-of-bounds exceptions when requesting a row that no longer exists).

    To be really fancy you can watch the filesystem and refresh the cache and then the outline view when changes are made to it.

    UPDATE: Further to this, as part of the cache you generally build a tree of the nodes in the outline view, using a data structure like this:

    @interface OutlineNode : NSObject
    {
        id _item;
        OutlineNode * __weak _parentNode;
        NSMutableArray *_childNodes;
    }
    

    and you can set specific nodes in the OutlineView, for example:

    - (BOOL)outlineView:(NSOutlineView *)outlineView
       isItemExpandable:(id)item
    {
        if (item == nil)
            return YES;
    
        OutlineNode *node = (OutlineNode *)item;
        return node.parentNode == nil;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.