• 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
Re: How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?


  • Subject: Re: How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?
  • From: mmalcolm crawford <email@hidden>
  • Date: Fri, 26 Nov 2004 18:11:37 -0800


On Nov 26, 2004, at 5:43 PM, Scott Ellsworth wrote:

I am trying to activate copy and paste for my Document-based Cocoa app. I want to copy and paste the data from my NSTableView to an external file. Since everything else about that NSTableView is using bindings, I figure there has to be a way to get the selected rows that way as well, but I cannot figure out how to get an NSArray of selected objects or selected object indices from my multiple selection.

Ask the array controller for its 'selectedObjects'.

Starting with the ToDos example at <http://homepage.mac.com/mmalc/CocoaExamples/controllers.html> you could add an outlet to the MyDocument class:

	IBOutlet NSArrayController *arrayController;

In the nib, connect that to the array controller.
Then implement a 'copy...' method (again in MyDocument), for example:

- (IBAction)copySelectedItems:sender
{
	NSLog(@"Copying %@", [arrayController selectedObjects]);
	// ...
}


The ToDos example is more complicated than is required for your immediate needs (in particular there is no necessity to subclass NSArrayController), however it does illustrate drag and drop from the table view which may be useful in the future. (You could implement the data source methods in MyDocument, but it may also be handy to re-use the array controller, especially if you want to support reordering.)


mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?
      • From: Scott Ellsworth <email@hidden>
    • Re: How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?
      • From: mmalcolm crawford <email@hidden>
References: 
 >How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side? (From: Scott Ellsworth <email@hidden>)

  • Prev by Date: How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?
  • Next by Date: Re: How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?
  • Previous by thread: How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?
  • Next by thread: Re: How do I get a multiple selection out of my NSArrayController and into an NSArray on the code side?
  • Index(es):
    • Date
    • Thread