• 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
NSSavePanel oddity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSSavePanel oddity


  • Subject: NSSavePanel oddity
  • From: "John C. Welch" <email@hidden>
  • Date: Sun, 17 Jan 2010 21:32:14 -0500
  • Thread-topic: NSSavePanel oddity

Title: NSSavePanel oddity
Okay, so something's not right here.

I've managed to figure out NSSavePanel a bit. I create the save panel, set the message, allowed file types, extension hidden, allows other file types, all this is working okay. Even managed to beat it through my skull that for bools, I need to use 1 and 0 not YES and NO no matter what the nice examples say. Life is good, even though at times, runModal() can take a while (ten seconds or more) to finally pop the dialog.

So this:
on createNewFile_(sender) --create a new file
       set theSavePanel to my NSSavePanel's savePanel() --create the save panel object
       theSavePanel's setMessage_("Create New Data File")
        theSavePanel's setAllowedFileTypes_(theFileTypeArray) --we want to be specific here, and only allow certain types, in our case, text
       theSavePanel's setExtensionHidden_(0) --in the AppleScriptObjC is not objectiveC file: for bools, use 1 or 0 not YES or NO
       --if you don't, you'll get fussed at and you'll never know why
       theSavePanel's setAllowsOtherFileTypes_(1) --yes we only want text, but we don't want to be dicks about it
       --if someone really wants to use .dat or whatever, fine, they can
       --theSavePanel's setNameFieldSTringValue_("File.txt")
       set theSavePanelResult to theSavePanel's runModal()
        --log theSavePanelResult
end createNewFile_

...is working fine. I get what I expect, life is good.

Now, I want to set a default filename in the filename field. Looking at the docs, I see that setNameFieldStringValue: should do this. Looking at the syntax, I see:

(void)setNameFieldStringValue:(NSString *)value

“Nice” I say, this should be cake, because it’s just like setMessage:

(void)setMessage:(NSString *)message

...and I’ve got setMessage working jes’ peachy! So, off I go:

theSavePanel's setNameFieldSTringValue_("File.txt")

However, that’s going to generate an error:

[NSSavePanel setNameFieldSTringValue:]: unrecognized selector sent to instance 0x2002ef760 (error -10000)

To which I cheerfully reply: “Huh” (well, with other words no suitable for this list in there. But they all come down to “huh”?

Is there something I’m missing about setNameFieldStringValue? (I hope it’s not the bloody STring typo, because I compiled and saved it once that way, and as we all know, AppleScript will never, ever let me fix that. So if it’s that, I’m rather buggered.)

--
solum juge de tuis difficultibus es tu

The only constant in your difficulties is you
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSSavePanel oddity
      • From: Chris Page <email@hidden>
    • Re: NSSavePanel oddity
      • From: Shane Stanley <email@hidden>
    • Re: NSSavePanel oddity
      • From: Craig Williams <email@hidden>
  • Prev by Date: Re: Creating/saving/appending to files the Cocoa way
  • Next by Date: Re: NSSavePanel oddity
  • Previous by thread: Re: Creating/saving/appending to files the Cocoa way
  • Next by thread: Re: NSSavePanel oddity
  • Index(es):
    • Date
    • Thread