I have a warning message when I load Game Center Leaderboards with:
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != nil) {
leaderboardController.leaderboardDelegate = self;
[self presentModalViewController:leaderboardController animated:YES];
}
Warning massage appears in third line, and It says:
warning: Semantic Issue: Assigning to
‘id’ from incompatible type
‘ViewMenuController *’
I understand the message but I don’t know how solve it.
The code works fine, but I would like remove the warning or find if there is a better way to load leaderboards.
Thanks in advance.
Solution:
I have done two modifications in ViewMenuController.h:
Add this import:
#import <GameKit/GameKit.h>
and modify this line adding :
@interface ViewMenuController : UIViewController <GKLeaderboardViewControllerDelegate> {
Thanks everybody for your help!
Best guess is when you are setting the
leaderboardDelegateto self, it is expecting aid<GKLeaderboardViewControllerDelegate>, but yourViewMenuControllerdoes not define itself as conforming to theGKLeaderboardViewControllerDelegateprotocol.Make sure you set this in the interface of
ViewMenuController.