开发者

Memory management issue: Object used after release

开发者 https://www.devze.com 2023-02-04 13:15 出处:网络
This code is returning an error: 458:3 Reference-counted object is used after it is released - (id)createObjectFromURL: (NSURL*)URL

This code is returning an error:

458:3 Reference-counted object is used after it is released

 - (id)createObjectFromURL: (NSURL*)URL
                    query: (NSDictionary*)query {
  id target = nil;

    if (self.instantiatesClass) 
  {
    target = [_targetClass alloc];
  } 

  else 
  {
    target = [_targetObject retain];
  }

  id returnValue = nil;
  开发者_如何学运维if (_selector) 
  {
    returnValue = [self invoke:target withURL:URL query:query];
  } 
  else if (self.instantiatesClass) 
  {
    returnValue = [target init];
  }

  [target autorelease];
  return returnValue;
}


What about if you try to do this:

else if (self.instantiatesClass) 
{
  returnValue = [[target init] autorelease];
}
return returnValue;

Because you're not init ing the target if you don't go to else if.

0

精彩评论

暂无评论...
验证码 换一张
取 消