I would like to know if there is a way to attach a NSDictionary
object to a cell that is displayed in a UITableView
, so when a cell is selected I can访问附加到该 tableviewcell 的 NSDictionary
。
最佳答案
当然,只需创建单元格的子类并添加字典即可。您也可以使用完全空的实现:
// MyCell.h
@interface MyCell : UITableViewCell
@property (nonatomic, strong) NSDictionary* dictionary;
@end
// MyCell.m
@implementation MyCell
@end
现在,如果您使用的是 Storyboard,请确保设置您的单元格类,或者如果您不是,则注册它,然后在您出队时设置字典,并在稍后取回单元格时读取它.
关于ios - 将字典对象附加到 UITableViewCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18501703/