Как мне получить доступ к полю пользовательского объекта в массиве NSMutable?

#iphone #ios

#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
  

У меня есть массив 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.
  

Ответ №1:

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

Комментарии:

1. добавьте еще одну строку .. прежде чем возвращать ячейку, сделайте это .. faxObject=nil;