Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property type 'id' is incompatible with type 'id' inherited from 'UIToolbar' warning

Tags:

ios

I just installed xcode 5 and I'm now receiving this warning. I've never seen it before. My app runs fine, but I hate seeing a warning. Does anyone know what this is and how to fix it? Thanks

Property type 'id' is incompatible with type 'id' inherited from 'UIToolbar'

like image 656
vboombatz Avatar asked Oct 09 '13 14:10

vboombatz


1 Answers

It is hard to tell from the lack of context, but this appears to be a duplicate of Syntax for resolving incompatible property type on inherited delegate

The problem is likely that you are creating a new property with the same name but with different protocols attached.

For example, UIToolBar has the following property:

@property(nonatomic, assign) id<UIToolbarDelegate> delegate;

If you were to declare the below in your class, it would generate this warning because the two properties have different protocols:

@property(nonatomic, assign) id<MyBetterDelegate> delegate;

There are two ways to solve this. You could modify your protocol to inherit from the other protocol:

@protocol MyBetterDelegate<UIToolbarDelegate>
...

Or you could modify your property definition to capture both protocols:

@property(nonatomic, assign) id<MyBetterDelegate, UIToolbarDelegate> delegate;
like image 90
Brian Nickel Avatar answered Nov 05 '22 11:11

Brian Nickel