iOS: What is a difference between dequeueReusableCell(withIdentifier:for:) and dequeueReusableCell(withIdentifier:)?

后端 未结 4 491
故里飘歌
故里飘歌 2021-01-13 18:23

According to the official documentation, there are two ways to get a reusable cell from a queue of a tableView. One is dequeueReusableCell(withIdentifier:for:)

4条回答
  •  清歌不尽
    2021-01-13 18:43

    Method dequeueReusableCell(withIdentifier:) is older than dequeueReusableCell(withIdentifier:for:), and the main difference between them is that first will return nil, if cell don't registered, the second will throw an exception, and an app will crash. IndexPath requires for height calculation(if defined tableView:heightForRowAtIndexPath)

提交回复
热议问题