views:

252

answers:

1

Hi all,

I recently started compiling my iPhone application against the 3.0 OS. The app worked fine when compiled against 2.2.1 however, compiling against 3.0 yields the following warning:

warning: type 'id ' does not conform to the 'UIActionSheetDelegate' protocol

This occurs on the 2nd line of the following code snippet which is in my app delegate class.

+ (PooClientAppDelegate*) instance;
{
    UIApplication* app = [[UIApplication sharedApplication] delegate]; // warning occurs here
    return (PooClientAppDelegate*)app;
}

I'm not sure where this error is coming from as it didn't appear when building against the older SDK's.

As another clue or piece of evidence, when running the app, none of the action sheets appear and instead the default choice for my actions sheets are automatically selected. I'm unsure whether this is related but sounds like a little more than a coincidence.

Any ideas whats going on here?

A: 

You've got a blatant error on this line:

UIApplication* app = [[UIApplication sharedApplication] delegate];

You're getting an instance of UIApplication, requesting its delegate, and then trying to assign the delegate into a UIApplication pointer.

It should be:

id<UIApplicationDelegate> app = [[UIApplication sharedApplication] delegate];

I'm not sure it'll exactly fix your error, but it's sure not correct the way you have it. =)

Dave DeLong
Duhh! Great that fixed it! My ActionSheet error was something entirely different.Out of curiousity the warning mentioned UIActionSheetDelegate - do you know why that is?
aloo
@aloo the -delegate method returns an id, and the first protocol that UIApplication implements is UIActionSheetDelegate. Since id doesn't implement that protocol, it was giving you an error. (That's a guess, but I'm pretty sure right)
Dave DeLong
*I'm pretty sure I'm right. (I wish we could edit comments...)
Dave DeLong