Note that there are some explanatory texts on larger screens.

plurals
  1. POIOS Potential Leak an Object Message
    primarykey
    data
    text
    <p>I am developing an IOS application. I am fully understand the logic of the memory management. I did analyze with Xcode instruments then I saw "Potential leak an object" message. What is wrong with the code below. Can you help me please ? </p> <pre><code>-(CountriesDTO*)getNationalityCountry{ NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; NSString *userNationality = (([def stringForKey:@"passCitizenshipCountry"]!=nil &amp;&amp; [def stringForKey:@"passCitizenshipCountry"]!=NULL)?[def stringForKey:@"passCitizenshipCountry"]:@""); CountriesDTO *ct = [self getCountryForCode:userNationality]; return ct; **//Potential leak of an object** } -(CountriesDTO*)getUserPhoneCodeCountry{ NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; NSString *userPhoneCode = (([def stringForKey:@"countryPhoneFlagCode"]!=nil &amp;&amp; [def stringForKey:@"countryPhoneFlagCode"]!=NULL)?[def stringForKey:@"countryPhoneFlagCode"]:@""); CountriesDTO *ct = [self getCountryForCode:userPhoneCode]; return ct; **//Potential leak of an object** } -(CountriesDTO*)getCountryForCode:(NSString*)candidateCode{ NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; NSString *userSiteCountry = (([def stringForKey:@"userSiteUrlCountry"]!=nil &amp;&amp; [def stringForKey:@"userSiteUrlCountry"]!=NULL)?[def stringForKey:@"userSiteUrlCountry"]:@""); NSString *defCode = @""; if (![candidateCode isEqualToString:@""]) { //Kullanıcının profilindeki nationality veya phone code dolu ise bu kullanılır. defCode = candidateCode; }else{ defCode=@"TR"; } DatabaseController *db = [[[DatabaseController alloc] init] autorelease]; CountriesDTO *ct = [db getCountry:defCode]; if (ct==nil) { ct = [[CountriesDTO alloc] init]; ct.countryCode_=@""; ct.countryId_=@""; ct.countryName_=@""; ct.countryPhoneCode_=@""; } return ct; **//Potential leak of an object** } -(CountriesDTO*)getCountry:(NSString*)countryCode{ CountriesDTO *model=[[[CountriesDTO alloc] init] autorelease]; if (![db open]) { [db release]; }else{ FMResultSet *s = [db executeQuery:[NSString stringWithFormat:@"SELECT * FROM country Where code ='%@'",countryCode]]; while ([s next]) { //retrieve values for each record [model setCountryId_:[s stringForColumn:@"id"]]; [model setCountryCode_:[s stringForColumn:@"code"]]; [model setCountryPhoneCode_:[s stringForColumn:@"phoneCode"]]; [model setCountryName_:[s stringForColumn:@"name"]]; } [db close]; } return model; } </code></pre> <p><img src="https://i.stack.imgur.com/oVRYm.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload