• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
removeObjectAtArrangedObjectIndexPath EXC_BAD_ACCESS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

removeObjectAtArrangedObjectIndexPath EXC_BAD_ACCESS


  • Subject: removeObjectAtArrangedObjectIndexPath EXC_BAD_ACCESS
  • From: Tony Romano <email@hidden>
  • Date: Thu, 27 May 2010 13:58:04 -0700

Below is some code that handles mount and unmount notifications for volumes.  During an unmount, I want to remove the item from the NSTreeController's arrangedObjects list.  The mount sections works fine, it appends to the tree any new volumes added.  When I want to unmount it, I go through the process of finding which NSTreeNode represents my object, get the index path to the tree node and call removeObjectAtArrangedIndexPath:tn .  This is where it access faults.  My debug output gives a valid row and the correct IndexPath.  I also verified via gdb console that the treenode is the correct item that contains my object that represents the volume.  Here is the call stack and the code.  Any ideas as to why it is crashing here?

Platform:
Mac OS X10.6.3, XCode 3.2.2

TIA,
-Tony Romano

call stack;
#0  0x00007fff87392160 in objc_msgSend_vtable2 ()
#1  0x00007fff81c2e4fd in __NSFastEnumerationMutationHandler ()
#2  0x000000010000316e in -[AppController workspaceNoticationHandler:] (self=0x100138d80, _cmd=0x100013844, notification=0x100547650) at AppController.m:176
#3  0x00007fff82bfd86e in _nsnote_callback ()
#4  0x00007fff81b7eaea in __CFXNotificationPost ()
#5  0x00007fff81b6b098 in _CFXNotificationPostNotification ()
#6  0x00007fff82bf47d8 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#7  0x00007fff828f77ad in volumeObserverCallback ()
#8  0x00007fff85adb113 in _FSVolumeObserverCallback ()
#9  0x00007fff81b9ac2e in __CFMachPortPerform ()
#10 0x00007fff81b73201 in __CFRunLoopRun ()
#11 0x00007fff81b718df in CFRunLoopRunSpecific ()
#12 0x00007fff8147cada in RunCurrentEventLoopInMode ()
#13 0x00007fff8147c8df in ReceiveNextEventCommon ()
#14 0x00007fff8147c798 in BlockUntilNextEventMatchingListInMode ()
#15 0x00007fff8223aa2a in _DPSNextEvent ()
#16 0x00007fff8223a379 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#17 0x00007fff8220005b in -[NSApplication run] ()
#18 0x00007fff821f8d7c in NSApplicationMain ()
#19 0x0000000100001b75 in main (argc=3, argv=0x7fff5fbff7d0) at main.m:13


	// Handle mount/unmount volumes
	if ([notifyName compare: @"NSWorkspaceDidMountNotification"] == NSOrderedSame) {
		id volume = [userInfo objectForKey:@"NSWorkspaceVolumeURLKey"];

		// create a new node and add it to the volume object then append to the content array
		Node * volumeMapEntry = [volumeNodes createAndAddNodeFor:volume isVol:YES];
		NSArray *childNodes = [[outlineController arrangedObjects] childNodes];
		NSIndexPath * path = [NSIndexPath indexPathWithIndex:[childNodes count]];
		[outlineController insertObject:volumeMapEntry atArrangedObjectIndexPath:path];
	}

	else if ([notifyName compare: @"NSWorkspaceDidUnmountNotification"] == NSOrderedSame) {
		id key = [userInfo objectForKey:@"NSWorkspaceVolumeURLKey"];
		NSString *volumeName = [[userInfo objectForKey:@"NSWorkspaceVolumeURLKey"] absoluteString];

		NSArray *childNodes = [[outlineController arrangedObjects] childNodes];

		for (NSTreeNode *tn in childNodes) {
			NSString *nodeName = [[[tn representedObject] nodeURL] absoluteString];

			if ([nodeName compare:volumeName] == NSOrderedSame) {
				NSUInteger row = [[outlineViewController outlineView] rowForItem:tn]; //for debug output
				NSIndexPath *path = [tn indexPath];
				NSLog(@"Row:%d, IndexPath:%@", row, path);
				[outlineController removeObjectAtArrangedObjectIndexPath:path];
			}
		}
	}

-Tony

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: removeObjectAtArrangedObjectIndexPath EXC_BAD_ACCESS
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Suppressing visibility in the Dock
  • Next by Date: Re: removeObjectAtArrangedObjectIndexPath EXC_BAD_ACCESS
  • Previous by thread: PMSessionGetCurrentPrinter issue
  • Next by thread: Re: removeObjectAtArrangedObjectIndexPath EXC_BAD_ACCESS
  • Index(es):
    • Date
    • Thread