开发者

Memory Leak warning

I have an array declared inside a user defined method. I use this array to store the values returned from the sqlite database. Then I use that value for further processing... But Xcode gives me the following warning at the array declaration. "Value stored during initialization is never being read" Here is my code:

 NSMutableArray *tempId=[NSMutableArray array];
NSString *sqlStr1=[NSString stringWithFormat:@"select deck_id from decksTable limit '%d' offset '%d'",1,deckID-1];
char *sql1 = (char*)[sqlStr1 UTF8String];
tempId=[appDelegate.dbConnection  fetchColumnFromTable:sql1 col开发者_如何学JAVA:0];
NSNumber *tempint1 =[tempId objectAtIndex:0];
int actualDeckID=[tempint1 intValue];

Please help me out of this.

Note dbConnection is the database connection object and fetchColumnFromTable is a user defined method which returns the array of values fetched from database. Then i get the first value in NSNumber and convert it into integer to use it in my code. I get the above warnning at the declaration of the tempId array.


NSMutableArray *tempId=[NSMutableArray array]; is not necessary as the memory allocated by this statement is not used and you are pointing tempId to the array returned at tempId=[appDelegate.dbConnection fetchColumnFromTable:sql1 col:0];. So basically you can just declare the array and not initialise it. NSMutableArray *tempId;

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜