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: Jens Alfke <email@hidden>
- Date: Thu, 23 Mar 2017 14:00:40 -0700
> 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