NSSelector question
NSSelector question
- Subject: NSSelector question
- From: Gian Carlo Cervone <email@hidden>
- Date: Wed, 4 May 2005 08:02:10 -0400
Hello:
I'm new to xCode (I'm using v. 1.1) and would appreciate any
suggestions on this problem.
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!");
}
Also, I'm a bit concerned that the fourth println indicates an
NSObjectiveCSelector instead of an NSSelector, but I think I've
followed Apple's examples, so I'm not sure how else to do it.
Thanks in advance for any help or ideas!
Best Regards,
Gian Carlo Cervone
Rochester, NY
_______________________________________________
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