2012-03-16 1 views
1

내 질문과 관련하여 UITable is not getting populated with NSMutableArray 여기에 파일 이름이 모두 있습니다. 그리고이 파일들은 'Resources'폴더에 저장됩니다. 이제 ios 시뮬레이터의 문서 폴더에있는 '샘플'이라는 하위 폴더에 저장된 파일에서 동일한 테이블을 채울 필요가 있습니다. 앞서 내가 여기xcode를 사용하여 Documents 디렉토리에서 파일 읽기

files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: 
    [[NSBundle mainBundle] bundlePath] error:nil]; 
search_results_array = [files filteredArrayUsingPredicate: 
        [NSPredicate predicateWithFormat:@"self BEGINSWITH[cd] 'h'"]]; 

파일과 search_results_array 모두가 배열 인 다음 코드를 사용하여 이런 짓을. 이제 독서는 자원에서 나온 것이 아닙니다. 나는 그것을 어떻게 편집 할 수 있는가? 아무도 도와주세요. 다음

답변

2

사용 :

NSFileManager *fileManager = [NSFileManager defaultManager]; 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //Library directory is not accessible via iTunes, Document directory is 
    NSString *docDirectory = [paths objectAtIndex:0]; //2 
    path = [docDirectory stringByAppendingPathComponent:yourString]; //3 
    files = [[NSDictionary alloc] initWithContentsOfFile: path]; 

가정 파일은있는 NSDictionary이다.