0
NSDictionary *bundle = [NSDictionary dictionaryWithObjectsAndKeys:message,@"message", toUserName, @"receiver",fromUserName, @"sender", nil];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:bundle];
NSOutputStream *outStream;
[toUser getInputStream:nil outputStream:&outStream];
[outStream open];
NSInteger bytes = [outStream write:[data bytes] maxLength: [data length]];
[outStream close];
success = YES;
NSLog(@"Wrote %ld bytes", bytes);
我得到:Wrote -1 bytes
。NSOutputStream給-1字節?
@anon:親愛的我,你是新來的Objective-C嗎?比我更糟? :D NSInteger不是一個對象,所以你不能在NSLog中使用對象說明符。 ;) – lolwut
我錯了,因爲其他原因,但你可以做我說的。但是,那麼'NSInteger'也必須成爲我所說的指針。 – Dair