Câu hỏi phỏng vấn Objective-C
Câu hỏi

What is the reuseIdentifier used for?

Câu trả lời

The reuseIdentifier is a property used in Objective-C, specifically when working with table views and collection views. It serves two main purposes:

  1. Reusing cells: When a table view or collection view needs to display a large amount of data, it can become inefficient to create a new cell object for each item. Instead, the view reuses existing cell objects that have scrolled off-screen. This process is known as cell reuse, and it helps optimize performance by reducing the number of cell objects that need to be created and destroyed.

  2. Identifying cell types: In a table view or collection view, you can have multiple types of cells, such as header cells, footer cells, and regular data cells. The reuseIdentifier allows you to specify a unique identifier for each type of cell. This identifier is used by the view to match dequeued cells with their corresponding cell types.

Here's an example of how reuseIdentifier is used in Objective-C:

- (UITableViewCell *)tableView:(UITableView *)tableView cellFor...
junior

junior

Gợi ý câu hỏi phỏng vấn

expert

What is Dynamic Dispatch and how does it work in Objective-C?

entry

Name four important data types found in Objective-C

senior

What are the reasons for using NSOperationQueue over GCD and vice versa?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào