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

Re: NSOpenPanel instantly closing


  • Subject: Re: NSOpenPanel instantly closing
  • From: Nick Forge <email@hidden>
  • Date: Mon, 19 Feb 2007 19:03:52 +1100


On 18/02/2007, at 10:35 PM, Keith Duncan wrote: - (IBAction)open:(id)sender { NSOpenPanel *panel = [NSOpenPanel openPanel]; // Run the open panel [panel beginSheetForDirectory:nil file:nil types:[NSImage imageFileTypes] modalForWindow:[stretchView window] modalDelegate:self didEndSelector: @selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL]; }

Might I suggest that stretchView is a nil pointer? That would cause the behavior you are seeing.


You're on the money, sort of. I had two stretchView instances, and my connections in IB were connected to the wrong one. So the [stretchView window] message was returning a nil pointer.


In more detail: http://forums.mactalk.com.au/showthread.php?t=28120



In order to deal with the situation of the modalForWindow: argument being a nil pointer you must bear in mind that [NSOpenPanel openPanel] returns an autoreleased object, and since you aren't starting a modal run loop inside that method of yours it gets released pretty quickly.

Yep, that's pretty much what was happening.


The solution is to retain the open panel in your open: method and release it in the openPanelDidEnd:returnCode:contextInfo: method.


Actually, the solution was to know what I was doing in IB! :)

Thanks to everyone for your time!


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSOpenPanel instantly closing (From: Nick Forge <email@hidden>)
 >Re: NSOpenPanel instantly closing (From: Keith Duncan <email@hidden>)

  • Prev by Date: Re: NSFileHFSTypeCode = 'brok'
  • Next by Date: Re: what is a valid key-path? why can't I bind to NSURL's -path method?
  • Previous by thread: Re: NSOpenPanel instantly closing
  • Next by thread: Re: NSOpenPanel instantly closing
  • Index(es):
    • Date
    • Thread