Sha*_* TK 2 iphone objective-c automatic-ref-counting
我正在尝试用ios5制作应用程序,我真的很困惑,为什么会发生这种情况.有人可以帮我解释一下为什么出现错误时出现错误
将非本地对象的地址传递给__autoreleasing参数以进行回写
以下调用导致错误
// note the following method returns _inStream and _outStream with a retain count that the caller must eventually release
if (![netService getInputStream:&_inStream outputStream:&_outStream]) {
NSLog(@"error in get input and output streams");
return;
}
Run Code Online (Sandbox Code Playgroud)
我的班级.h
NSInputStream *_inStream;
NSOutputStream *_outStream;
@property (nonatomic, strong) NSInputStream *_inStream;
@property (nonatomic, strong) NSOutputStream *_outStream;
Run Code Online (Sandbox Code Playgroud)
我的班级.m
@synthesize _inStream;
@synthesize _outStream;
Run Code Online (Sandbox Code Playgroud)
所述的getInputStream是NSNetService类方法
请在下面的NSNetService类getInputStream实现
/* Retrieves streams from the NSNetService instance. The instance's delegate methods are not called. Returns YES if the streams requested are created successfully. Returns NO if or any reason the stream could not be created. If only one stream is desired, pass NULL for the address of the other stream. The streams that are created are not open, and are not scheduled in any run loop for any mode.
*/
- (BOOL)getInputStream:(NSInputStream **)inputStream outputStream:(NSOutputStream **)outputStream;
Run Code Online (Sandbox Code Playgroud)
我找到了相关的帖子
但是我无法找到问题
对此问题的任何帮助表示赞赏
谢谢
我找到了解决方案
开始了.将变量创建为本地变量并将它们分配回原始变量.感谢@borreden的深刻见解.
这是我的最新代码.
NSInputStream *tempInput = nil;
NSOutputStream *tempOutput = nil;
// note the following method returns _inStream and _outStream with a retain count that the caller must eventually release
if (![netService getInputStream:&tempInput outputStream:&tempOutput]) {
NSLog(@"error in get input and output streams");
return;
}
_inStream = tempInput;
_outStream = tempOutput;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4176 次 |
最近记录: |