2011-05-31 96 views
0

我有這樣的自定義對象:如何訪問NSMutable數組中的自定義對象字段?

#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 

我的NSMutableArray(remoteRecipientItems)陣列含有FaxRecipient對象。

不過我想只是使用名稱設置一個UITableView單元格的值:

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

回答

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

非常感謝。還有很多要學習。欣賞幫助 – milof 2011-05-31 05:05:21

+0

加入這一行more..before返回單元格做這個.. faxObject = nil; – Suny 2011-05-31 05:56:28

相關問題