Re: What is the best way to deprecate a protocol method?
Re: What is the best way to deprecate a protocol method?
- Subject: Re: What is the best way to deprecate a protocol method?
- From: Jim Adams <email@hidden>
- Date: Thu, 23 Mar 2017 21:08:26 +0000
- Thread-topic: What is the best way to deprecate a protocol method?
Yeah, we want them to move but we want to give them a grace period. If we add the parameter to the method and they recompile, won’t it complain? Just checking which method the have implemented doesn’t sound quite good enough. Heck we have to check which one to call do that anyway but we want a compiler warning and not a compiler error.
> On Mar 23, 2017, at 5:00 PM, Jens Alfke <email@hidden> wrote:
>
>
>> On Mar 23, 2017, at 1:49 PM, Jim Adams <email@hidden> wrote:
>>
>> Not sure exactly where to post this but I thought I would start here. We have a Framework for iOS which has a delegate protocol defined. We have decided that one of the methods needs to start sending back a new parameter.
>
> You haven’t said exactly what your goal is. It sounds like you want client apps to get a compiler warning if they don’t upgrade to the new version of the protocol?
>
> I think what I would do is twofold:
> (a) Change the method in the protocol to add the new parameter. Or in other words, remove the old method and add the new one with the extra parameter.
> (b) Before you call the new delegate method in your framework, call -respondsToSelector: to see whether it’s implemented. If it’s not, call the old method instead (and maybe log a warning.)
>
> This preserves binary compatibility, but flags the usage of the deprecated method. Unfortunately it flags it as an error not a warning, but that will get developers to update more quickly :)
>
> —Jens
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden