0

奇妙な問題があります

サーバー送信機能

-(void) writeToServer:(const uint8_t *) buf {
    NSLog(@"sending buf %s with lenght %zd", buf, strlen((char*)buf));
    [oStream write:buf maxLength:strlen((char*)buf)]; 
     // NSOutputStream *oStream
}

buf

NSLog(@"converted %@ length %d", encrypted, [encrypted length]);
// encrypted is NSMutableData
return (const uint8_t*)[encrypted bytes]; 

出力

 converted <4b010000 00000006 00000000 00000f20 30303031 4e50> length 22
 sending buf K with lenght 2

同じままにするために buf が必要です..同じ raw バイトと適切な長さで、どうすればよいですか?

4

1 に答える 1

1

NSDataオブジェクトを直接渡します。

-(void)writeToServer:(NSData *)data
{
    NSLog(@"sending with length %lu", (unsigned long)[data length]);
    [oStream write:[data bytes] maxLength:[data length]]; 
}
于 2013-01-23T07:58:48.580 に答える