сохранить в NSUserDefaults:
[[NSUserDefaults standardUserDefaults]setObject:yourArray forKey:@"theArray"];
получить его из NSUserDefaults:
[[NSUserDefaults standardUserDefaults]objectForKey:@"theArray"];
установить значения из массива в UITableViewCell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"TheCell";
UITableViewCell *_cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (_cell == nil) {
_cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
_cell.textLabel.text = [yourArray objectAtIndex:indexPath.row];
return _cell;
}
Надеюсьпомогает
обновить
, на данный момент поблизости нет Mac, поэтому мой ответ может быть немного небрежным.
В вашем заголовочном файлене забудьте добавить UITableViewDelegate и UITableViewDataSource, поэтому это будет выглядеть примерно так:
@interface yourController : UIViewController <UITableViewDelegate, UITableViewDataSource, ... some others if you need it ...> {
, затем в файле реализации (.m) вы можете просто начать набирать
-tableview
а затем используйте автозаполнение, чтобы получить методы, которые вам нужны.Скорее всего, вам понадобятся эти 3:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- (void)tableView: (UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath
, в зависимости от потребностей вашего приложения, вам может понадобиться их больше, но эти 3 должны быть там.
Для получения дополнительной информации о UITableView, пожалуйста,проверьте эту ссылку: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableView_Class/Reference/Reference.html