trueinViso
trueinViso

Reputation: 1394

What exactly does it mean to assign to strong from incompatible type?

I am having a hard time finding an explanation of what it means to assign to __strong from incompatible type. I'd like to understand the message instead of how to fix a specific instance.

I understand that __strong means that I will own the object. For example:

info = [ADMCoreFactory newServiceInfoWithURI:[queue uri]];

In this case I am getting a warning that I am assigning '__strong id<ADMServiceInfo>' from incompatible type 'ADMCoreFactory *'

Does this mean that ADMCoreFactory needs to 'own' the object and my id<ADMServiceInfo> object needs to be a weak reference?

This is the method declaration from the header file:

+ (id<ADMServiceInfo>)newServiceInfoWithURI:(NSString *)anURI; 

Upvotes: 0

Views: 387

Answers (1)

Rob Napier
Rob Napier

Reputation: 299355

'__strong id<ADMServiceInfo>' from incompatible type 'ADMCoreFactory *'

This is telling you that ADMCoreFactory does not conform to the ADMServiceInfo protocol, and so you can't assign it to a variable of that type. __strong here is a bit of a red herring. It is technically part of the type, but it's not the important part in this case.

It is possible that you expect +newServiceInfoWithURI: to return some other type than ADMCoreFactory, in which case you have probably incorrectly declared it. Make sure there are no other warnings being issued. You should have no warnings at all in ObjC code.

Upvotes: 2

Related Questions