我使用這個代碼來加載內容的NSArray和它似乎做工精細但儀器檢測泄漏點存在,我不能把我的手指上了一個問題:加載文件內容的NSArray
- (void) loadPlan: (NSString *) fName
{
short j1;
fName= [NSString stringWithFormat:@"/%@", fName];
[self NewCase];
NSArray *arrayPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [arrayPaths objectAtIndex:0];
NSString *filePath = [docDirectory stringByAppendingString:fName];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath];
if (!fileExists) return;
NSString *fileContents = [NSString stringWithContentsOfFile:filePath
encoding:NSUTF8StringEncoding error:nil];
NSArray *chunks = [fileContents componentsSeparatedByString: @"#"];
for (i = 0; i <= 100; i++)
{
InputV[i] = [[chunks objectAtIndex: i+5] doubleValue];
}
...
for (j1 = 0; j1 <= 10; j1++)
{
GroupMode[j1] = [[chunks objectAtIndex: 206+j1] retain];
}
...
}
,並在init方法在某處,我有:
for (j1 = 0; j1 <= 10; j1++)
{
GroupMode[j1] = [[NSString alloc] initWithFormat:@""];
}
儀器指向NSAraay *塊行代碼,但我不知道有什麼問題。我需要在某個時候發佈它嗎?
我很感激任何幫助。
你是如何管理內存的?您正在使用ARC,GC還是手動內存管理? – 2012-08-09 12:44:01
@Analog文件我使用任何默認的方法,我沒有發起任何事情。例如,如果我有:pool = [[NSAutoreleasePool alloc] init]; Items = [[NSMutableArray alloc] initWithCapacity:91]; 然後在dealloc方法中我有[Items release]; – 2012-08-09 12:51:49