我正在使用 NSOutputStream 将数据从客户端(IOS 设备)输出到服务器(PC 设备)。我可以成功地将数据发送到服务器,我只想使用 NSOutputStream 添加当前时间。
如何使用 NSOutputStream 发送当前时间?
这是我的代码
- (IBAction)button1:(id)sender {
NSString *response = @" Today's Sunny \n ";
NSData *data = [[NSData alloc] initWithData:[response dataUsingEncoding:NSASCIIStringEncoding]];
[outputStream write:[data bytes] maxLength:[data length]];
NSDate *currentTime = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"hh:mm:ss"];
_timer.text = [formatter stringFromDate:currentTime];
//_timer is A label just for testing
///I'm trying to use outputStream to output currentTime like this
/// [outputStream write:[currentTime bytes] maxLength:[CurrentTime length]];
}