my both code is working good..but i wants to know..who is better…
and which i use ?
first code…..
NSString *advance=[[NSString alloc]initWithFormat :@"Pay in Advance Rs %i",pro.s_advance ];
UILabel *label1 =[[UILabel alloc]initWithFrame:CGRectMake(10,5,200,40)];
label1.text=advance;
[cell.contentView addSubview:label1];
[label1 release];
[advance release];
and second code is…..
UILabel *label1 =[[UILabel alloc]initWithFrame:CGRectMake(10,5,200,40)];
label1.text=[NSString stringWithFormat:@"Pay in Advance Rs %i",pro.s_advance ];
[cell.contentView addSubview:label1];
[label1 release];
The first and second codes are equal.
The only difference is that in second one you are creating
autoreleasedobject of typeNSString. In first one you are releasing manually object of typeNSStringas it is notautoreleased:[advance release];So there are no memory management issues and you can use any of that approaches.
I would prefer second one as code will be more cleaner.