• 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: 10.3 problem...or me
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 10.3 problem...or me


  • Subject: Re: 10.3 problem...or me
  • From: Ambroise Confetti <email@hidden>
  • Date: Thu, 30 Oct 2003 23:39:07 +0100

Le 30 oct. 03, ` 21:28, Bo Gunn a icrit :

> I have written an application which needs reference to a filename (or
> filenames) opened by the user at many different times. A solution that
> works on Jaguar is defined a global variable NSOpenPanel *panel and
> defining
> two functions
>
> (1) - (NSArray *) panel_filenames
> {
> return [panel filenames];
> }
>
> And
> (2) - (unsigned) panel_filenames_count
> {
> return [[panel filenames] count]];
> }
>
> This method works fine on Jaguar but fails on Panther. I get a
> BAD_ACCESS
> error upon the second time I call the first function. Any ideas (or
> constructive criticism)?

How do you initialize your "panel" variable? Could you provide us with
some code? The only way I know of doing that is to use [NSOpenPanel
openPanel] which returns the shared NSOpenPanel instance (would it be
safe to allocate and initialize one manually?). So you don't need to
store your panel anywhere -- just call [NSOpenPanel openPanel] when you
need it.
A BAD_ACCESS error likely means that your panel instance is no longer
valid.

Anyway I wouldn't do it like that. I would copy the filenames array
when the user validates and keep the array for later use without caring
about the panel. (Besides, I don't know what happens to the panel's
internal filenames array when the user cancels.)

Constructive criticism:
- It is unusual to put underscores in method names. Better names would
be panelFilenames and panelFilenamesCount (there is a page about naming
conventions in the Cocoa doc).


Ambroise

http://www.cellulo.info/
ICQ 4508259
AIM atvaark

[demime 0.98b removed an attachment of type text/directory which had a name of Ambroise Confetti.vcf]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >10.3 problem...or me (From: Bo Gunn <email@hidden>)

  • Prev by Date: NSStatusBar and image
  • Next by Date: screen garbage after print operation
  • Previous by thread: 10.3 problem...or me
  • Next by thread: Re: 10.3 problem...or me
  • Index(es):
    • Date
    • Thread