ios - Memory leak reported by instrument. Can't understand why -


instruments telling following method leaking memory when creating mutable string. can tell me why? using arc on ios 8 xcode 6.2.

 - (nsstring *)capitalizefirstletter {         if (self.length == 0) {             return self;         }         nsmutablestring * string = [nsmutablestring stringwithstring:self.lowercasestring];         [string replacecharactersinrange:nsmakerange(0, 1) withstring:[self substringtoindex:1].capitalizedstring];         return string;     } 

i not sure caused leak, if want avoid can change method to:

- (nsstring *)capitalizefirstletter {     if (self.length == 0) {         return self;     }     return [nsstring stringwithformat:@"%@%@", [self substringtoindex:1].capitalizedstring, [self substringfromindex:1]]; } 

also review answeres here need fixing memory leak - nsmutablestring


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -