Re: Instancetype and refactoring methods
Re: Instancetype and refactoring methods
- Subject: Re: Instancetype and refactoring methods
- From: Alex Zavatone <email@hidden>
- Date: Mon, 09 Nov 2015 15:08:14 -0500
- X_v_e_cd: 635d4ba30656acd5cee74451055a128e
- X_v_r_cd: ebf4d76309813a1560a995da909d7d2d
Thanks. It appears that the instancetype didn't help, as I had already converted the init method to return the instancetype instead of id.
Yeah, oddly enough, the object that's conforming to the protocol is using delegate/protocol and calling a method in the delegate - which isn't even declared in the protocol. I don't know how it worked in the first place.
Spooky code is spooky.
Thanks, Jens. Always appreciated.
On Nov 9, 2015, at 2:20 PM, Jens Alfke wrote:
>
>> On Nov 9, 2015, at 10:58 AM, Alex Zavatone <email@hidden> wrote:
>>
>> Before I give it a shot, is this a case where using instancetype to return the instance of the object that holds the method a better choice than id?
>
> It sounds like your delegate API is using the old “informal protocol” mechanism where you declare the methods in a category on NSObject. Instead, it’s best to define a protocol for the delegate type and always refer to the delegate using that protocol. (You’ve probably seen that AppKit and Foundation switched over to this a few years ago.)
>
> —Jens
_______________________________________________
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