On Nov 29, 2010, at 12:31 PM, David Rowland wrote:

> When I build, I get a warning,
> 
> type 'id <UIApplicationDelegate>' does not conform to the 
> 'UIAccelerometerDelegate' protocol

Whatever is being referred to on the line you are getting this warning is only 
typed as "id<UIApplicationDelegate>" so the compiler doesn't know that the 
object actually corresponds to the UIAccelerometerDelegate protocol as well. If 
you know better, you can type cast to silence the warning (since I imagine you 
are using [[UIApplication sharedApplication] delegate] to get the value).

> Yet in running, the method is called and behaves as it should. It is the only 
> method in the protocol, and it's optional. How could I fail to conform to the 
> protocol?


Objective-C is a dynamic enough language that it cannot fully check for 
conformance at compile time (which is why the message above is a warning and 
not an error). Technically you don't even need to conform to the protocol, you 
can just implement the methods and go, but implementing the protocol allows for 
error checking by the compiler – but only when the compiler can actually see 
the protocol declarations in the first place (which is not the case above).
--
David Duncan

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to