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 protected]) 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]
