I'm trying to port the following Java code to Objective C.
myByteBuffer = new ByteArrayOutputStream(myCfA.length() + 1);
myByteBuffer.write(myCfA.getBytes());
myByteBuffer.write(new byte[]{0});
myWriter.write(myByteBuffer.toByteArray());
myWriter.flush();
It's relevant Objective-C code
NSInteger strLength = self.myCfA.length;
NSMutableString *response = [NSMutableString stringWithCapacity:strLength];
[response appendString:self.myCfA];
[response appendString:@"0"];
NSData *data = [[NSData alloc] initWithData:[response dataUsingEncoding:NSUTF8StringEncoding]];
NSInteger bytesCount = [self.outputStream write:[data bytes] maxLength:[data length]];
Is my approach of taking NSMutableString and then converting into NSData and getting bytes a correct approach? Also for new byte[]{0} I'm directly appending 0 as string. Please correct me if I'm going wrong. There is an issue here which I'm unable to trace out.
Thanks Sudheer