Weitere ähnliche Inhalte
Ähnlich wie サーバーからiOSアプリを変更する (20)
サーバーからiOSアプリを変更する
- 17. 独自UITableViewControllerの設定
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
!
NSURL *url = [NSURL URLWithString:self.strEndPoint];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSErro
*error) {
NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:data options:
error:nil];
self.items = [jsonDictionary valueForKeyPath:self.strField];
[self.tableView reloadData];
}];
}
Storyboardで設定されたstrEndPointの値
Storyboardで設定されたstrFieldの値
- 19. 独自UILabelの設定
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath
{
//(いつもの処理)
NSDictionary* dict = [self.items objectAtIndex:indexPath.row];
NSArray* cellSubviews = cell.contentView.subviews;
for( UIView* control in cellSubviews){
if( [[[control class] description] isEqualToString:@"UIEntityLabel"]){
UIEntityLabel* label = (UIEntityLabel*)control;
NSString* strData = [dict valueForKeyPath:label.strEntity];
label.text = strData;
!
}
}
return cell;
}