이 작업을 수행하는 방법이 궁금한 경우 그냥 누수가 없는지 확인하고 싶지만 문자열 내용 만 수정한다고 생각합니다.루프에서 문자열을 작성/삭제하는 올바른 방법입니까?
NSMutableString *newPath = [[NSMutableString alloc] init];
for(fileName in [manager enumeratorAtPath:rootPath]){
if ([[fileName pathExtension] isEqual:@"exr"]) {
[fileArray addObject:fileName];
// THIS BIT
[newPath setString:rootPath];
[newPath appendString:@"/"];
[newPath appendString:fileName];
// HERE
attrDir = [manager attributesOfItemAtPath:newPath error:&myError];
fileSize = [attrDir objectForKey: @"NSFileSize"];
NSLog(@"File: /%@ Size: %@", fileName, fileSize);
}
}
[newPath release];
게리가
흠 내가 추가하는 시도 [newpath를 stringByAppendingPathComponent : @ "/"]; 끝 부분에 "/"를 추가하여 테스트 할 수 있지만 제대로 작동하지 않는 것 같습니다 ... – fuzzygoat
stringByAppendingPathComponent는 구분 기호에 대해 알 필요가 없도록합니다. 사용법을 반영하도록 답변을 업데이트했습니다. – nall
감사합니다. 그래서 무엇을 추가해야할지 어떻게 알 수 있습니까? – fuzzygoat