Bonjour,
Je suis en train d'apprendre l'objective C et le développement Iphone. Ma bête noire en ce moment, c'est la gestion de la mémoire.
Voici, un exemple qui me pose problème parmi d'autres :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| - (void)setBalise:(id)sender{
NSMutableString *str = [self.text mutableCopy];
NSRange r = [self selectedRange];
if (r.location == NSNotFound) {
return;
}
NSString *selectedStr = [str substringWithRange:r];
NSString *newStr = [NSString stringWithFormat:@"<mabalise>%@</mabalise>", selectedStr];
[str replaceCharactersInRange:r
withString:newStr];
self.text = str;
} |
Dans ce code, peut importe son fonctionnement, je vois que l'on a recours à des NSString, à des NSRange, mais à aucun moment on ne fais de release une fois qu'on a fini de les utiliser.
Pourriez-vous m'expliquer pourquoi ?
Partager