Trying to create an app that does some socket communication (Writing only).
I can get it to work with a static val开发者_开发问答ue:
UInt8 buf[] = "play";
int bytesWritten = CFWriteStreamWrite(writeStream, buf, strlen((char*)buf));
I'm a relative neophyte to C/Objective-C and I'm trying to figure out how to pass an NSString to a function and get the value into "buf".
-(void) sendData: (NSString *) command {
    UInt8 buf[] = ????;
    int bytesWritten = CFWriteStreamWrite(writeStream, buf, strlen((char*)buf));
}
Obviously more to it than that...just isolating the relevant code.
You can access the bytes behind an NSString using the UTF8String method.
CFWriteStreamWrite(writeStream,
                   (const UInt8 *)[command UTF8String],
                   [command lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论