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

I just installed xcode 5 and now I get this warning. I've never seen this before. My application is working fine, but I hate to see a warning. Does anyone know what it is and how to fix it? Thanks

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

+6
source share
3 answers

Hard to say due to lack of context, but it seems like duplicate syntax for resolving an incompatible property type of an inherited delegate

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

For example, a UIToolBar has the following property:

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

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

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

There are two ways to solve this problem. You can change your protocol to inherit another protocol:

 @protocol MyBetterDelegate<UIToolbarDelegate> ... 

Or you can change your property definition to capture both protocols:

 @property(nonatomic, assign) id<MyBetterDelegate, UIToolbarDelegate> delegate; 
+15
source

Yes, because you can declare an id property in your class with the name delegation, and UIToolbar has a property identifier with the same name. Just change the name of your class to something like myClassDelegate, and it will clear the warning.

Syntax for resolving an incompatible property type of an inherited delegate

0
source

You should not use the id property in your objects - it is reserved for C. object objects

Change it to something like "toolbarId" - that's great.

-1
source

Source: https://habr.com/ru/post/955585/


All Articles