关于设置日期的代码

在开发过程中,设置日期是必不可少的:

//获取用户选择的时间
    NSDate *date = self.dataPicker.date;
    //把NSdat转换成一个字符串
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    formatter.dateFormat = @"HH:mm";
    NSString *strDate = [formatter//把用户选择的日期设置给当前选中的cell中的label
    //获取用户当前选中的cell
    //根据当前选中行获取当前选中行的索引
    NSIndexPath *index = [self.tableView indexPathForSelectedRow];
    //根据当前选中索引获取当前选中的cell
    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:index];
    
    //把日期设置给cell中的label
    cell.detailTextLabel.text = strDate;
原文地址:https://www.cnblogs.com/ZMiOS/p/5026058.html