如何访问NSMutableArray中的自定义对象字段?

时间:2011-05-31 04:56:13

标签: iphone ios

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

 #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.

1 个答案:

答案 0 :(得分:5)

FaxRecipient *faxObject= [remoteRecipientItems objectAtIndex:indexPath.row];//This is ur object
cell.textLabel.text=faxObject.name;//this sets the name