开发者

Xcode - warning problem

开发者 https://www.devze.com 2023-03-11 07:37 出处:网络
I have a navigation controller that utilizes an if statement to switch between the different views, and when i run it it comes up with a warning on the line:

I have a navigation controller that utilizes an if statement to switch between the different views, and when i run it it comes up with a warning on the line:

ROSS_APP_7AppDelegate *dele开发者_StackOverflowgate = [[UIApplication sharedApplication] delegate];

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

I'd like some help on how to get rid of this warning. Here is the whole if statement:

if(indexPath.row == 0)
{
    MapDetailController *mapD = [[MapDetailController alloc] initWithNibName:@"MapDetailController" bundle:nil];
    self.mapDetailController = mapD;
    [mapD release];

    mapDetailController.title = [NSString stringWithFormat:@"%@", [moreArray objectAtIndex:row]];

    ROSS_APP_7AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
    [delegate.moreNavController pushViewController:mapDetailController animated:YES];


}

Thanks

EDIT: Here is what my AppDelegate looks like (response to answer #2)

#import <UIKit/UIKit.h>
@class MoreNavController;
@interface ROSS_APP_7AppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIWindow *window;
IBOutlet UITabBarController *tabBarController;
IBOutlet MoreNavController *moreNavController;
}


@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@property (nonatomic, retain) IBOutlet MoreNavController *moreNavController;
@end


You probably forgot to have your app delegate conform to the UITabBarControllerDelegate protocol.

To implement it, your appDelegate header should look like this (the @interface declaration is the relevant line):

#import ...

@interface ROSS_APP_7AppDelegate : AppDelegate_Shared <UITabBarControllerDelegate> 
{
    ....
}

@property(nonatomic, retain) .....

@end

You might be using AppDelegate_Shared / AppDelegate_iPhone / AppDelegate_iPad so bear in mind that the above example considers a shared app delegate

EDIT:

After seeing your comment,

Try replacing:

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

With this:

ROSS_APP_7AppDelegate *delegate = (ROSS_APP_7AppDelegate*)[[UIApplication sharedApplication] delegate];

Does typecasting the return like this get rid of your warning?


Have you tried casting the delegate as in:

(id)[[UIApplication sharedApplication] delegate];

???

0

精彩评论

暂无评论...
验证码 换一张
取 消