• 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: NSOpenPanel obsolete method?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOpenPanel obsolete method?


  • Subject: Re: NSOpenPanel obsolete method?
  • From: Ali Ozer <email@hidden>
  • Date: Mon, 2 Jul 2001 19:34:33 -0700

> Is this "new Class[]" thing a Java thing? I can only tell you that my
> (Objective-C) code looks like this.

Yup. For reference, here's Cocoa/Java code to bring up the sheet (and to
process it when torn down). The new Class[] thing is part of the
NSSelector creation --- you are creating an array of Classes, and
putting one class --- the class of the receiver of the selector --- in
it. Also note the syntax for the selector itself. The contextInfo is
your optional user data; in ObjC it can be anything; in Java it has to
be an object (and null is OK).

Ali


public void openMenu(NSMenuItem sender) {
NSOpenPanel op = new NSOpenPanel();
op.setAllowsMultipleSelection(false);
op.setCanChooseDirectories(false);
op.setCanChooseFiles(true);
op.beginSheetForDirectory(
directoryName, // dir name
null, // file name
null, // file types
window, // window to attach sheet to
this, // callback object
new NSSelector("done::", new Class[]
{getClass()}), // callback
null); // context info (to be passed to the callback)
}

public void done(NSOpenPanel sheet, int returnCode, Object
contextInfo) {
NSSystem.log("called callback");
if (returnCode == NSAlertPanel.DefaultReturn) {
NSSystem.log("Success! file name is " + sheet.filename());
}
}


References: 
 >Re: NSOpenPanel obsolete method? (From: Joe Muscara <email@hidden>)

  • Prev by Date: Re: boolean into NSDictionary
  • Next by Date: Re: Custom Property List Question
  • Previous by thread: Re: NSOpenPanel obsolete method?
  • Next by thread: Working with serial ports
  • Index(es):
    • Date
    • Thread