• 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: Prevent Asynchronous operation of beginSheetModalForWindow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Prevent Asynchronous operation of beginSheetModalForWindow


  • Subject: Re: Prevent Asynchronous operation of beginSheetModalForWindow
  • From: Graham Cox <email@hidden>
  • Date: Sat, 28 Jun 2008 14:16:40 +1000


On 28 Jun 2008, at 12:38 am, John Love wrote:

[code snipped]

Finally, you nailed it, almost (one small bug, see below). Phew!


========

Okay ... all the snippets are done ... now, the questions:

(1) warning: no doSheetSelection:contextInfo method found which, I think, is
due to the fact that the external class of mFileSheetDelegate =
FileController, yet when referenced in SaveSheetController, it's = id, a
general pointer. But, I thought all anonymous pointers were resolved at
runtime ... am I just going to force myself to ignore this Build Warning,
knowing that it will all go away at runtime???


The reason for this is because the sheet controller is not aware of your File Controller's methods. Nor should it be. So how to resolve it? The answer is to declare the callback method as an informal protocol *within SheetController.h* Thus:

@interface NSObject (SheetSelectionDelegate)

- (void) doSheetSelection:(int)returnCode contextInfo: (void*)contextInfo;

@end

Now, your sheet controller does know that there is a method that has this signature, so the warning will go away. But because the method is defined as a category of NSObject, you still have avoided exposing SheetController to the inner workings of your FileController. This is the more precise, and correct meaning of "informal protocol", and generally you implement them as categories on NSObject.

(2)I still get "unrecognized selector" .. but,

That's because you're targeting the wrong object. Here:

[NSApp beginSheet:[self window]
modalForWindow:parentWindow
modalDelegate:theTarget // <---------------------- uh-oh
didEndSelector:@selector
(sheetDidEnd:returnCode:contextInfo:)
contextInfo:contextInfo];


You should be passing 'self', not 'theTarget' as modalDelegate. Why? Because it is the sheet controller that is the modal delegate of the *sheet*, which is what this specifies. The target is the delegate of the sheet *controller*, so the sheet itself doesn't want this. You already dealt with that by recording the target in your own ivar.

You have got to get these relationships straight in your mind. It's not that hard. I've goaded and prompted you and written your code for you piece by piece - that's great, it solves your problem. But has it increased your understanding? I fear it hasn't, and it still all seems like voodoo. I'm not sure what I can do about that.

cheers, Graham


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


  • Follow-Ups:
    • Re: Prevent Asynchronous operation of beginSheetModalForWindow
      • From: "John Love" <email@hidden>
References: 
 >Prevent Asynchronous operation of beginSheetModalForWindow (From: "John Love" <email@hidden>)
 >Re: Prevent Asynchronous operation of beginSheetModalForWindow (From: "John Love" <email@hidden>)
 >Re: Prevent Asynchronous operation of beginSheetModalForWindow (From: Graham Cox <email@hidden>)
 >Re: Prevent Asynchronous operation of beginSheetModalForWindow (From: "John Love" <email@hidden>)
 >Re: Prevent Asynchronous operation of beginSheetModalForWindow (From: "John Love" <email@hidden>)
 >Re: Prevent Asynchronous operation of beginSheetModalForWindow (From: "John Love" <email@hidden>)
 >Re: Prevent Asynchronous operation of beginSheetModalForWindow (From: Graham Cox <email@hidden>)
 >Re: Prevent Asynchronous operation of beginSheetModalForWindow (From: "John Love" <email@hidden>)

  • Prev by Date: Re: while loop with sleep(): logging works, but not UI events
  • Next by Date: Re: simple question about passing around pointers to objects
  • Previous by thread: Re: Prevent Asynchronous operation of beginSheetModalForWindow
  • Next by thread: Re: Prevent Asynchronous operation of beginSheetModalForWindow
  • Index(es):
    • Date
    • Thread