zoukankan      html  css  js  c++  java
  • ios id与NSobject的区别

    id 与NSobject的区别:
    id会自动判别类型并转换

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        //把列表数组中的 对象取出, 该对象有可能是日期对象,也有可能是新闻列表对象
        id/ NSObject * object = self . allnewsLists[indexPath.row];
    
        //如果取出的是日期对象, 创建日期cell,并返回日期cell
        if ([object isKindOfClass:[Date class]]) {
            DateCell *dateCell = [tableView dequeueReusableCellWithIdentifier:@"dateCell" forIndexPath:indexPath];
            dateCell.date = object;
            return  dateCell;
            
        }
        //如果取出的是新闻列表对象, 创建列表cell,并返回列表cell
        NewsListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"newsListCell" forIndexPath:indexPath];
        cell.newsList = object;
        return cell;
    }
    
    成功的三大原则: 1、坚持 2、不要脸 3、坚持不要脸
  • 相关阅读:
    java-第二周学习总结
    春季总结
    第十二周作业
    第十一周作业
    第十周作业
    第九周作业
    第八周作业
    网络层思维导图
    数据链路层思维导图
    Mysql数据库的基本操作之建表操作(2)
  • 原文地址:https://www.cnblogs.com/xulinmei/p/7420220.html
Copyright © 2011-2022 走看看