Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 在NSObject类中实现时未调用IOS GCDAsyncSocket didReadData_Objective C_Gcdasyncsocket - Fatal编程技术网

Objective c 在NSObject类中实现时未调用IOS GCDAsyncSocket didReadData

Objective c 在NSObject类中实现时未调用IOS GCDAsyncSocket didReadData,objective-c,gcdasyncsocket,Objective C,Gcdasyncsocket,我在NSObject类中实现GCDAsyncSocket委托,然后在viewController中调用它。 运行它时,我发现调用了'didConnectToHost'和'didWriteDataWithTag',但没有看到调用'didReadData'。这是我的密码: SocketUtils.h @interface SocketUtils : NSObject <GCDAsyncSocketDelegate> @property (nonatomic) void (^SocketC

我在NSObject类中实现GCDAsyncSocket委托,然后在viewController中调用它。 运行它时,我发现调用了'didConnectToHost'和'didWriteDataWithTag',但没有看到调用'didReadData'。这是我的密码:

SocketUtils.h

@interface SocketUtils : NSObject <GCDAsyncSocketDelegate>
@property (nonatomic) void (^SocketCallback)(id data);
@property (nonatomic) NSString *message;
@property (nonatomic) UIViewController *vc;
+ (SocketUtils *) createSocket:(NSString *)message inViewController:(UIViewController *)vc;
- (void) connectToSocket;
@end
然后在viewController中,我调用:

socketUtils = [SocketUtils createSocket:@"GET_BOARD_CODE" inViewController:self];
    socketUtils.SocketCallback = ^(id data) {
        doSth();
    };
我预测的第一件事是这个类的毁灭,但我试图保持所有@property=strong,但不起作用


有人能帮忙吗?

经过多次搜索,我意识到我忘了在邮件中添加“\r\n”。好的,只需将1行代码更改为:

this.message = [message stringByAppendingString:@"\r\n"];
它的工作正如预期的那样

this.message = [message stringByAppendingString:@"\r\n"];