NSLinguisticTagger内存泄漏

我一直在用iOS 5.0的新的NSLinguisticTagger在Xcode 4.2中摆弄。 我用这个函数的目标是获取一个地址簿logging,然后把一个合成名称作为一个NSString来分发,就像ABRecordCopyCompositeName所做的一样,但是考虑到东亚语言和匈牙利语的命名顺序(倒数第一,而不是倒数第一) )。 这个function:

NSString *text = [self getLocalizedFullNameOfRecord:[contacts objectAtIndex:indexPath.section]; - (NSString *) getLocalizedFullNameOfRecord:(ABRecordRef) person { NSString *firstName = ABRecordCopyValue(person, kABPersonFirstNameProperty); NSString *middleName = ABRecordCopyValue(person, kABPersonMiddleNameProperty); NSString *lastName = ABRecordCopyValue(person, kABPersonLastNameProperty); NSString *prefix = ABRecordCopyValue(person, kABPersonPrefixProperty); NSString *suffix = ABRecordCopyValue(person, kABPersonSuffixProperty); NSString *fullName = @""; __block BOOL Asian; // Apologies to all Hungarians who aren't actually Asian __block NSArray *asianLanguages = [NSArray arrayWithObjects:@"zh-Hant", @"zh-Hans", @"ja", @"ko", @"hu", @"vi", nil]; [firstName enumerateLinguisticTagsInRange:NSMakeRange(0, firstName.length) scheme: NSLinguisticTagSchemeLanguage options: NSLinguisticTaggerOmitWhitespace orthography: nil usingBlock:^(NSString *tag, NSRange tokenRange, NSRange sentenceRange, BOOL *stop){ if ([asianLanguages containsObject:tag]) Asian = YES; else Asian = NO; }]; if(prefix) fullName = [fullName stringByAppendingFormat:@"%@ ", prefix]; if(Asian && lastName) fullName = [fullName stringByAppendingFormat:@"%@ ", lastName]; else if(firstName) fullName = [fullName stringByAppendingFormat:@"%@ ", firstName]; if(middleName) fullName = [fullName stringByAppendingFormat:@"%@ ", middleName]; if(Asian && firstName) fullName = [fullName stringByAppendingFormat:@"%@ ", firstName]; else if(lastName) fullName = [fullName stringByAppendingFormat:@"%@ ", lastName]; if(suffix) fullName = [fullName stringByAppendingFormat:@"%@", suffix]; [firstName release]; [middleName release]; [lastName release]; [prefix release]; [suffix release]; return fullName; } 

仪器告诉我,我在这个函数的每一次迭代中,在枚举语言标记(而不是块部分,显然)上泄漏了大约16到32个字节。 由于NSLinguisticTagger的在线资源仅限于其类参考和单个教程,所以我不知道在哪里以及如何开始寻找泄漏。

请帮助?

我有同样的问题。 在我的情况下,当string有换行符(\ n或\ r)时发生泄漏。