【问题标题】:How do I access a custom object field within a NSMutable Array?如何访问 NSMutableArray 中的自定义对象字段?
【发布时间】:2011-05-31 13:07:40
【问题描述】:

我有一个自定义对象,例如:

 #import <Foundation/Foundation.h>


    @interface FaxRecipient : NSObject {


        NSString * contactID;
        NSString * name;
        NSString * fax;
        NSString * company;
        NSString * phone;

    }
    @property(nonatomic,retain)NSString *contactID;
    @property(nonatomic,retain)NSString *name;
    @property(nonatomic,retain)NSString *fax;
    @property(nonatomic,retain)NSString *company;
    @property(nonatomic,retain)NSString *phone;

    @end

我有一个包含 FaxRecipient 对象的 NSMutableArray (remoteRecipientItems) 数组。

但是我试图通过使用名称来设置 UITableView 单元格的值:

[[cell textLabel]setText:[remoteRecipientItems objectAtIndex:[indexPath row]]]; //I want to only use the name value of FaxRecipient. Sorry for the newbie question.

【问题讨论】:

    标签: iphone ios


    【解决方案1】:
    FaxRecipient *faxObject= [remoteRecipientItems objectAtIndex:indexPath.row];//This is ur object
    cell.textLabel.text=faxObject.name;//this sets the name
    

    【讨论】:

    • 再添加这一行..在返回单元格之前执行此操作..faxObject=nil;
    猜你喜欢
    • 2012-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多