objective c - return dictionary leak cause crash -
i have confusion me property object this
nsmutabledictionary* spradsettingvaluebylinkcode; @property (nonatomic, retain) nsmutabledictionary * spradsettingvaluebylinkcode;
and synthesize in .m file like
@synthesize spradsettingvaluebylinkcode = _spradsettingvaluebylinkcode;
then using property setting value return function that
_spradsettingvaluebylinkcode = (nsmutabledictionary*)[_dbobject initwithspradersetting:inputlinkcode];
well issue
1) assign property not retain when use dictionary table view
2) if allocate
_spradsettingvaluebylinkcode = [[nsmutabledictionary alloc] initwithdictionary:[_dbobject initwithspradersetting:inputlinkcode]];
then can't release because app crash , if not release memory leak
so below code if working me perfect not looking right me need ask doing right or wrong?
// method use load view of spreadersettings - (void) loadspreadersettingsvalues:(nsstring*)inputlinkcode { [_spradsettingvaluebylinkcode removeallobjects]; if (!_dbobject) [self loaddbaccessdatabase]; [_spradsettingvaluebylinkcode release]; // relase previos retain object maintain count 1 _spradsettingvaluebylinkcode = (nsmutabledictionary*)[_dbobject initwithspradersetting:inputlinkcode]; [_spradsettingvaluebylinkcode retain]; [_productanalysistitlelabel settitle:[_spradsettingvaluebylinkcode objectforkey:@"description"]]; [_tbspreadersetting reloaddata]; } - (dbaccess *) loaddbaccessdatabase { // nslog(@"%s", __function__); _dbobject = [dbaccess shareddbobjectaccess]; return _dbobject; }
Comments
Post a Comment