Re: NSSelector question
Re: NSSelector question
- Subject: Re: NSSelector question
- From: Ricky Sharp <email@hidden>
- Date: Wed, 04 May 2005 07:24:16 -0500
On Wednesday, May 04, 2005, at 07:02AM, Gian Carlo Cervone <email@hidden> wrote:
>I'm new to xCode (I'm using v. 1.1) and would appreciate any
>suggestions on this problem.
If needing to stay with Xcode 1.x, you may want to at least move to version 1.2, but preferably 1.5.
>CONTEXT: I'm trying to get a certain method (tableRowDoubleClicked) to
>run when an uneditable row in an NSTableView is clicked. I am writing
>this project in Java.
>
>IMMEDIATE PROBLEM: my program doesn't seem to recognise the method I've
>created. Specifically, NSSelector.implementedByClass is returning
>false for the method in question.
>
>QUESTION: Is it enough to define the method and then create a selector
>to it, or do you need to somehow register it before it will be seen?
>What have I done wrong here or left out?
>
>Here is the code I'm using, from a custom class definition:
>
>==============================
> private NSTableView fileNames; /* IBOutlet */
> public NSSelector theSelector;
>
> theSelector = new NSSelector("tableRowDoubleClicked", new Class[]
>{null});
>
> fileNames.setTarget(null);
> fileNames.setDoubleAction(theSelector);
>System.out.println(theSelector.implementedByClass(DirectoryBrowser.class
>));
>System.out.println(theSelector.name());
>System.out.println(fileNames.target());
>System.out.println(fileNames.doubleAction());
>try{
>System.out.println(theSelector.methodOnClass(DirectoryBrowser.class));
>}
>catch(NoSuchMethodException e) {
>System.out.println("noSuchMethod");
>}
>=================================
>
>and here is the output:
>
>
>false
>tableRowDoubleClicked
>null
>NSObjectiveCSelector tableRowDoubleClicked:
>noSuchMethod
>
>
>I would have expected the first line to be true since I have a method
>defined:
>
>
> public void tableRowDoubleClicked() { /* IBAction */
>System.out.println("Double-clicked!");
> }
I haven't done any Cocoa work with Java, but shouldn't the IBAction methods take a 'sender' parameter? In that case, your selector name would then be tableRowDoubleClicked: (note the colon at the end).
Of course then modify the second parm passed to the NSSelector constructor.
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
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