내비게이션 컨트롤의 테이블보기에있는 디렉토리에 파일을 나열하고 싶습니다. 디렉터리에 파일을 표시합니다. 하지만 아래로 스크롤 할 때마다 시뮬레이터가 충돌합니다. 문제가 무엇입니까? dirArray는 .h 파일에서 NSArray * dirArray로 정의됩니다.contentsOfDirectoryAtPath가 충돌 함
- (void)viewDidLoad {
[super viewDidLoad];
NSString *path = [[NSFileManager defaultManager]currentDirectoryPath];
NSFileManager *fileManager = [NSFileManager defaultManager];
dirArray = [fileManager contentsOfDirectoryAtPath:path error:nil];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section {
return [dirArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
NSString *fileName = [dirArray objectAtIndex:indexPath.row];
cell.textLabel.text = fileName;
return cell;
}
이 충돌 로그를 제공 할. – Ishu