当尝试使用 IF 语句从通过蓝牙接收到的数据中调用方法时,它不会结合
那里还有我需要删除的额外数据包吗?
-(IBAction) btnSend:(id) sender
{
//---convert an NSString object to NSData---
NSData* data;
NSString *str = [NSString stringWithString:txtMessage.text];
data = [str dataUsingEncoding: NSASCIIStringEncoding];
[self mySendDataToPeers:data];
}
- (void) receiveData:(NSData *)data
fromPeer:(NSString *)peer
inSession:(GKSession *)session
context:(void *)context {
//---convert the NSData to NSString---
NSString* str;
str = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSString* test = str;
NSString* up = @"up";
if (test == up)
{
[self up];
}
else
{
str = @"Not Vaild";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Data received"
message:str
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}