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:

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

junior

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

middle

What is the difference between NSDictionary and NSMutableDictionary ?

middle

What are some limitations and problems you can face with categories?

junior

What are blocks and how are they used?

Bình luận

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

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