I tried the application for testing Bluetooth connectivity. This is a simple application that simply sends a text message from one iDevice to another. Initially, there were about 6 warnings in this application, but I fixed everything but two. They are the same, but deal with different delegates. One for GKPeerPickerControllerDelegate and one for GKSessionDelegate. Let's say the Picker error for a GKPeerPickerController named picker when you enter (a more complete example):
picker.delegate = self;
the compiler says:
Passing '* const ___ strong' to a parameter of incompatible type 'id'.
For a session named GKSession, enter
session.delegate = self;
makes the compiler say:
Sending '* const ___ strong' to a parameter of incompatible type 'id'.
They only appear in the submit button and peerPickerController. I know that these warnings do not interfere with the functions of the application, but I would like to completely update this for Xcode 4.2. This app was originally written for Xcode when iOS 3.0 was new. Yes, I'm a little picky when it comes to writing or practice code, it should not contain any errors / warnings when possible.
These are blocks of code in which a warning occurs:
-(IBAction)btnConnect:(id)sender{ picker = [[GKPeerPickerController alloc] init]; picker.delegate = self; //Warning here picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby; [connect setHidden:YES]; [disconnect setHidden:NO]; [picker show]; } -(void)peerPickerController:(GKPeerPickerController *)PCpicker didConnectPeer:(NSString *)peerID toSession:(GKSession *)session{ self.currentSession = session; session.delegate = self; //Warning here [session setDataReceiveHandler:self withContext:nil]; PCpicker.delegate = nil; [PCpicker dismiss]; }
Edit:
The header has the following:
@interface BTViewController : UIViewController{ GKSession *currentSession; IBOutlet UITextField *txtMessage; IBOutlet UIButton *connect; IBOutlet UIButton *disconnect; GKPeerPickerController *picker;
}
source share