objective-c – error“将非本地对象的地址传递给__autoreleasing参数以进行回写”

objective-c – error“将非本地对象的地址传递给__autoreleasing参数以进行回写”,第1张

概述我把我的套接字客户端转换为ARC: - (id)initWithHostname:(NSString *)hostname AndPort:(NSInteger)port{ if((self = [super init])) { oBuffer = [[NSMutableData alloc] init]; iBuffer = [[NSMutabl 我把我的套接字客户端转换为ARC:

- (ID)initWithHostname:(Nsstring *)hostname AndPort:(NSInteger)port{    if((self = [super init]))    {        oBuffer = [[NSMutableData alloc] init];        iBuffer = [[NSMutableData alloc] init];        iStream = [[NSinputStream alloc] init];        oStream = [[NSOutputStream alloc] init];        [Nsstream getStreamsToHost:[NSHost hostWithname:hostname] port:port inputStream:&iStream outputStream:&oStream];        ...    }    return self;}

我得到的错误是:

file://localhost/…foo.m: error: automatic Reference Counting Issue: Passing address of non-local object to __autoreleasing parameter for write-back

在“& iStream”/“& oStream”的此行上

[Nsstream getStreamsToHost:[NSHost hostWithname:hostname] port:port inputStream:&iStream outputStream:&oStream];

任何帮助?

解决方法 这个错误通常是由于非局部变量地址被传递给一个方法。因为变量被声明为__strong默认值,而方法的参数是__autoreleasing,所以声明方法的参数被调用__strong,像这样: (voID)method:(ID * __strong *)para。 请注意,头文件(.h文件)中的方法必须声明为与.m文件相同 总结

以上是内存溢出为你收集整理的objective-c – error“将非本地对象的地址传递给__autoreleasing参数以进行回写”全部内容,希望文章能够帮你解决objective-c – error“将非本地对象的地址传递给__autoreleasing参数以进行回写”所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1042506.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存