Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mpramodjain

macrumors regular
Original poster
Nov 20, 2008
152
0
Banglore
Hi,

I had the following method returning an object allocated.

Code:
-(UILabel*)getCustomUILabelObject{
UILabel *lLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,0,320,400)];
return lLabel;
}

-(void)loadView{

UILabel *lCustomUILabel=[self getCustomUILabelObject];
[lCustomUILabel release];
lCustomUILabel=nil;
}
So while using the Clang Static Analyzer , It is reporting following bug at return value.

leak returning value.
 
Last edited:
1) This forum has nothing to do with Apple. There is not point filling "Bug Reports" here.

2) That is not a bug. The well defined memory management conventions for Cocoa are that methods return autoreleased objects. So getCustomUILabelObject should return an autoreleased UILabel. This is not what you are doing.
 
Clang reports on any violations of the Cocoa naming conventions. Methods that return retained objects must be named with new or create in them. You've named your method with get in it so your method should follow the get rule, which it does not.

Change the method name to newCustomUILabelObject and Clang won't object.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.