• 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: NSSelector question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSelector question


  • Subject: Re: NSSelector question
  • From: String Larson <email@hidden>
  • Date: Wed, 4 May 2005 08:12:43 -0500


On May 4, 2005, at 7:24 AM, Ricky Sharp wrote:

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.
Yes.
eg.
public void generate(Object sender) { /* IBAction */
doSomething();
}
Method generate() is connected to a button w/in IB.

This:
http://developer.apple.com/documentation/Cocoa/Conceptual/LanguageIntegration/Tasks/usingselectors.html#//apple_ref/doc/uid/20000869
gives a good example of how to define the selector with the method signature you want.



--
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

 _______________________________________________
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: NSSelector question
      • From: Gian Carlo Cervone <email@hidden>
References: 
 >NSSelector question (From: Gian Carlo Cervone <email@hidden>)
 >Re: NSSelector question (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Re: Spotlight problem
  • Next by Date: Re: Spotlight problem
  • Previous by thread: Re: NSSelector question
  • Next by thread: Re: NSSelector question
  • Index(es):
    • Date
    • Thread