Xcode raising “incompatible pointer types sending ‘subclassA’ to parameter of type ‘subclassB’ ” warning. Compiling with clang.
In the case where the warning is raised, I use a
[subclassA isKindOfClass: [subclassB class]] ...
to ensure compatible pointer use. I’d like something like:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
// warning-raising code
#pragma clang diagnostic pop
but for the appropriate warning raised. I.e. Whats the clang flag to ignore the specified diagnostic?
Thanks for your time.
If I understand you right, you’re saying something like
The fix here is to cast
subclassAafter the successful type assertion. Your case is a bit odd in that you’re dynamically determining the type ofsubclassBinstead of testing for a static type, but in the method-someMethodThatWantsSubclassB:you definitely know the type involved, so you’d write something likeIf you have some really weird setup where you don’t actually know the static type of
subclassB(although I can’t imagine the situation here) you could simply cast to(id)instead to get rid of the warning: