Re: Editing nib files in XCode 4 and other stuff
Re: Editing nib files in XCode 4 and other stuff
- Subject: Re: Editing nib files in XCode 4 and other stuff
- From: Eli Bach <email@hidden>
- Date: Sat, 30 Apr 2011 14:04:29 -0600
On Apr 30, 2011, at 10:33 AM, John Love wrote:
> I've just converted my long-standing XCode 3 project to XCode 4. I was very fortunate in that the only change I had to make was because the call to -setDelegate was changed from:
>
> - (void )setDelegate:(id)delegate
> to:
> - (void )setDelegate:(id < NSToolbarDelegate >)delegate
> - (void )setDelegate:(id < RunPortDelegate >)delegate
>
> for one class's ToolbarCategory and for my RunPortCategory for another Class.
>
> (1) For what reason did they make that change to -setDelegate .. just plain ole (id) worked ??
Well, the class probably requires that the delegate implement all the methods of the specified protocol, so by adding the protocol to the declaration, the compiler can check and notify you if you try to set the delegate with an instance of a class that doesn't implement the given protocol. In the worst case [where the instance is stored in an 'id' variable that's not easy to change to the actual class of the instance], you can just typecast it to the expected type [after making sure the instance does implement the protocol, of course].
Eli
_______________________________________________
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