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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to