ios - Autorelease objects in ARC -


suppose in database manager singleton.

+ (swdatabasemanager *)retrievemanager {     @synchronized(self)     {        if (!sharedsingleton)        {            sharedsingleton = [[swdatabasemanager alloc] init];        }        return sharedsingleton;     } }  - (nsarray *)getproductdetails:(nsstring *)somestring  {     nsarray *temp = [self getrowsforquery:somestring];     return temp; }  - (nsarray *)getrowsforquery:(nsstring *)sql {     sqlite3_stmt *statement=nil;     nsmutablearray *arrayresults = [nsmutablearray arraywithcapacity:1];     //     //fetching data database , adds them in arrayresults     //     return arrayresults; } 

now view controller calling function of database manager this....

[self getproductservicedidgetdetail:[[swdatabasemanager retrievemanager] getproductdetail: @"somequery"]  - (void)getproductservicedidgetdetail:(nsarray *)detailarray  {     [self setdatasource:[nsarray arraywitharray:detailarray]];     [self.tableview reloaddata]; } 

questions ... when arrayresult of getrowsforquery release?

do need assign nil detailarray of getproductservicedidgetdetail?

is there memory leaks?

suggestion appreciated.

arc automatic memory management. releases (your array), when done using it.

arc works adding code @ compile time ensure objects live long necessary, no longer. conceptually, follows same memory management conventions manual reference counting (described in advanced memory management programming guide) adding appropriate memory management calls you.

to understand better might want read apples docs on arc.

you not need assign nil array, nor have worry memory leaks.

you not have (indeed cannot) release instance variables, may need invoke [self setdelegate:nil] on system classes , other code isn’t compiled using arc.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -