我通過一個聊天消息應用程序的教程工作,我在ViewController.m代碼類型,但我得到這些錯誤消息:錯誤消息「解析問題預計標識或‘(’」
預計標識或解析文檔版本「(」
(在下面的代碼中的第一粗線)和
語義文檔版本的方法定義爲「initNetworkCommunication」不 發現
(在下面的代碼中的第2個粗線)
我怎樣才能解決這些問題?注:我使用的Xcode 6.4
#import "ViewController.h"
@interface ViewController()
**- (void)initNetworkCommunication; {**
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@ 192.168.99.2, 80, &read-Stream,&writeStream);
inputStream = (NSInputStream *)readStream;
outputStream = (NSOutputStream *)writeStream;
[inputStream setDelegate:self];
[outputStream setDelegate:self];
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoop-Mode];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode: NSDefaultRunLoop-Mode];
[inputStream open];
[outputStream open];
[self initNetworkCommunication];
}
@end
**@implementation ViewController**
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)joinChat:(id)sender {
}
@end
分號實際上是有效的(但毫無意義)。 – rmaddy
當我應用您的建議更改時,我收到來自Xcode的錯誤3警報消息。聲明CFStreamCreatePairWithSocketToHost消息的行的第一條警告消息消息是「意外的接口名稱」NSStream':預期表達式「在聲明[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop})的行的第二條警報消息消息是」使用未聲明的標識符「模式''以及在聲明[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] [使用未聲明的標識符'模式'的模式')的行的第三條和最後一條警報消息。「 –