我已经为了这个功能来检查从UDP连接IOS比较两个NSString的
- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag
{
NSString *response = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *hello = @"hello";
if(response == hello){
[self debugPrint:[NSString stringWithFormat:@"ok"]];
}
else{
[self debugPrint:[NSString stringWithFormat:@"Read: \n%@",response]];
}
[response release];
}
我发送“你好”,但它不会再回来了“OK”的消息来的数据,它会跳转到其他{ }
谁能帮助谢谢
thanx您的答案,但你的代码不能正常工作,我尝试了NSLOG(响应),并在调试屏幕中收到了你好,但是如果每次都返回false。另外,如果我尝试类似: NSString * hello = @“hello”; NSString * hello2 = @“hello”; if([hello2 isEqualToString:hello]){} if返回true .. pf im confused! –