I tried out an app to test bluetooth communication. It is a simple app that just sends a message in text form from one iDevice to another. Originally, this app had about 6 warnings but I fixed all but two. They are the same but deal with different delegates. One is for the GKPeerPickerControllerDelegate and the other for the GKSessionDelegate. Say the Picker error is for the GKPeerPickerController named picker, when you type (more complete example to follow):
picker.delegate = self;
the compiler says:
Passing '*const___strong' to parameter of incompatible type 'id'.
For the GKSession named session, typing
session.delegate = self;
makes the compiler say:
Sending '*const___strong' to parameter of incompatible type 'id'.
These only pop in the button to send and peerPickerController. I know that these warnings do not impede on the app's ability to function but I would like to completely update this for Xcode 4.2. This app was originally written for Xcode back when iOS 3.0 was new. Yes, I am a bit picky when it comes to writing or practicing code, it must not contain any errors/warnings whenever possible.
These are the code blocks where the warning occur:
-(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 this:
@interface BTViewController : UIViewController{
GKSession *currentSession;
IBOutlet UITextField *txtMessage;
IBOutlet UIButton *connect;
IBOutlet UIButton *disconnect;
GKPeerPickerController *picker;
}
-Wall
always has less problems than otherwise. – Lutyens