Отображение NSArray файлов в UITableView - iOS 5
У меня есть приложение, которое позволяет пользователям сохранять и открывать текстовые файлы. Сохранение и открытие файлов довольно просты и просты, но я должен дать пользователю простой способ выбрать файл для открытия. Я решил сделать это сUITableView.
Когда TableView загружается в мой контроллер представления, моя цель состоит в том, чтобы заполнить TableView именами всех текстовых файлов пользователя из папки «Документы» (часть изолированной программной среды приложения iOS).
У меня есть общее представление о том, как это сделать:
Get the contents of the Documents folder and place it in an array
<code>NSString *pathString = [[NSBundle mainBundle] pathForResource:@"Documents" ofType:@"txt"]; NSArray *fileList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pathString error:nil]; NSLog(@"Contents of directory: %@", fileList); </code>
But this always returns: (null)
in the output window. What is the path for my app's document folder?
Place the array in the UITableView
I figured I'd use the numberOfRowsInSection
method to do this. Is this the right place for performing this type of operation? Of should I use a different method?
Finally, the app will get the value of the selected cell and use that value to open the file.
Мой главный вопрос здесь:How can I place items (particularly the contents of directory) into an NSArray and then display that array in a UITableView?
Любая помощь высоко ценится!