0

I have a super class like this:

@protocol AOCellDelegate;

@interface AOBaseCell : UITableViewCell
@property (nonatomic, weak) id<AOCellDelegate>delegate;
// ... other stuff ...
@end

Where AOCellDelegate is declared in a separate AOCellDelegate.h file (not all controllers will care to be the cell delegate, so I don't want to force them to import it).

I have a subclass of AOBaseCell that looks like this:

@protocol AOTextCellDelegate;

@interface AOTextCell : AOBaseCell
@property (nonatomic, weak) id<AOTextCellDelegate>delegate;
// ... other stuff...
@end

Where AOTextCellDelegate is declared in AOTextCellDelegate.h as conforming to AOCellDelegate like this:

@protocol AOTextCellDelegate <AOCellDelegate>
// ... methods ...
@end

Xcode / Clang incorrectly gives this warning:

property type 'id<AOTextCellDelegate>' is incompatible with type 'id<AOCellDelegate>' inherited from 'AOBaseCell'

It is compatible because AOTextCellDelegate conforms to AOCellDelegate, but Clang can't tell this because AOTextCellDelegate.h isn't imported in AOTextCell.h.

How can I tell Xcode / Clang to ignore this warning on this file only?

Per this other StackOverflow question, I believe that I need to use #pragma to ignore it. However, I don't see a warning identifier specified in the log (just the above message).

Community
  • 1
  • 1
JRG-Developer
  • 12,454
  • 8
  • 55
  • 81
  • Just as a note, you can find the warning message name in the debug output pane, if you expand the warning in question (It's the rightmost icon on the left pane, you will see the details after selecting the build session in question) – borrrden Apr 08 '14 at 01:59

1 Answers1

0

I couldn't figure out a way to use #pragma to silence this warning. However, I was able to let Clang know that the subclass delegate property was compatible with the super delegate property by doing the following:

@protcol AOCellDelegate; // technically, not needed because it's imported from super header
@protocol AOTextCellDelegate;

@interface AOTextCell : AOBaseCell
@property (nonatomic, weak) id<AOCellDelegate, AOTextCellDelegate>delegate;
// ... other stuff...
@end
JRG-Developer
  • 12,454
  • 8
  • 55
  • 81