• 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
NSArrayController's "selectionIndex" weirdness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSArrayController's "selectionIndex" weirdness


  • Subject: NSArrayController's "selectionIndex" weirdness
  • From: Johnny Lundy <email@hidden>
  • Date: Thu, 10 Apr 2008 22:09:17 -0400

Hello all,

In a TableView column bound to an NSArrayController which has playerArray, a mutable array, as its content.

An NSButton binding selectionIndex of the controller as the Argument 1, and the Selector Name to the method below, here's what I get in the method:

- (void) nightKill:(NSUInteger) theWhackedOne
{
	NSLog(@"SelectionIndex=%@",theWhackedOne);
	[playerArray removeObjectAtIndex:theWhackedOne];
	return;
}

When array item 0 is selected in the TableView, and the button clicked, the method is invoked. Cool.

The NSLog (with the format as "%@" you see above displays

SelectionIndex=0

Which is correct. It also displays 1, 2, 3, and 4 as the subsequent items are selected.

But the removeObjectAtIndex errors with rangeError, a large integer.

The selectionIndex is an NSUInteger, right? But in the GUI debugger, the value of theWhackedOne is some huge integer. Also, if I change the NSLog to format as "%d" instead of "%@", I get that huge integer.

"[theWhackedOne intValue]" gives an error - invalid assignment type - can't take the intValue of an integer, I guess.



How can this be? It apparently wants me to cast this object as an integer, but it is already an integer. When formatting it with NSLog as an object, I get the correct value (the index of the selected item in the array), but when using it as an integer I get a huge number that looks like a pointer.

I would appreciate any insight. The NSLog is giving the correct values but nothing else can change this parameter to the correct integer.
_______________________________________________


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: NSArrayController's "selectionIndex" weirdness
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Question about NSTreeController/NSOutlineView instance cleanup
  • Next by Date: Re: Question about NSTreeController/NSOutlineView instance cleanup
  • Previous by thread: Re: Why might DO/NSConnection fail?
  • Next by thread: Re: NSArrayController's "selectionIndex" weirdness
  • Index(es):
    • Date
    • Thread