error “Passing address of non-local object to __autoreleasing parameter for write-back”

后端 未结 3 2026
别跟我提以往
别跟我提以往 2020-12-29 03:22

I\'m converting my socket client to ARC:

- (id)initWithHostname:(NSString *)hostname AndPort:(NSInteger)port
{
    if((self = [super init]))
    {
        oB         


        
3条回答
  •  感动是毒
    2020-12-29 04:03

    This error is usually due to the non local variable address is passed to a method. Because the variable is declared as __strong by default, while the parameter of the method is __autoreleasing, so declare the parameter of the method invoked as __strong,like this: -(void)method:(id * __strong *)param.

    Note that the method in the header file (.h file) must be declared as the same of the .m file.

提交回复
热议问题