Why won't removeObjectAtIndex_ work?


G'day

I'm trying to use a button to remove a single selected item from a table.

The table is bound to a Mutable array 'theGraphData'.

For some reason this won't work. Any ideas why please?

Regards

Santa

on removeNewClient_(sender)
		set vClickedRow to my ClientToGraph's selectedRow() as integer
		--set vArrangedDS to arrangedObjects of my theclientdata -- theArrayController 
		--set vRow2Move to vArrangedDS's objectAtIndex_(vClickedRow)
		--set stringToFind to (vRow2Move's valueForKey_("GraphClient")) as text
		tell theArrayController to set my theGraphData to arrangedObjects() as list
		my theGraphData's removeObjectAtIndex_(vClickedRow)
	end removeNewClient_

You can’t call a Cocoa method on a list; it has to be anNSArray. And setting the bound variable to the array controller’s arrangedObjects seems a circular argument; I’m surprised it doesn’t cause problems.

What you probably want is this:

on removeNewClient_(sender)
       tell theArrayController 
set theItems to selectedObjects()
 removeObjects_(theItems)
   end removeNewClient_
end tell

Thanks Shane

Works a treat, although I did have to transpose the end and end tell :stuck_out_tongue:

Regards

Santa