ios - 将字典对象附加到 UITableViewCell

标签 ios objective-c nsmutablearray nsarray nsdictionary

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/

相关文章:

objective-c - 返回可变对象与返回不可变(非成员)对象

ios - InAppSettingsKit 动态单元格? (iPhone 和 iPad)

javascript - Dropbox 选择按钮在 ios8 中不返回

ios - NSMutableArray 如何在 swift 中使用 let 添加对象

ios - UIImageWriteToSavedPhotosAlbum()不保存裁剪的图像

ios - 如何正确拆除多点连接 session ?

ios - 如何在 Swift 中将 NSMutableArray 作为对 NSMutableDictionary 部分的引用传递?

ios - 在独立的 UINavigationBar 上应用栏指标

ios - 从 Twilio 客户端直接调用另一个 Twilio 客户端

ios - 如何将核心数据对象从 MapView 发送到 DetailView