开发者

Memory management issue: Object used after release

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜