Как получить доступ к объекту из модели данных (NSobject) на основе NSArray?

У меня есть массив, который выполнил и объединил несколько пользователей QBUUser ниже.

2018-01-24 12:05:33.095197+0400 samplechat[70177:6634702] COMBINEDARRAY(

  "
  [QBUUser]:
  ID:25957858
  created at:2017-04-04 11:06:17 +0000
  updated at:2017-12-18 06:03:52 +0000
  externalUserID:0
  blobID:0
  facebookID:(null)
  twitterID:(null)
  twitterDigitsID:(null)
  full name:rothessa balinario  sevilla
  email:[email protected]
  login:6395
  phone:3
  tags:(null)
  lastRequestAt:2017-12-18 06:06:22 +0000
  customData:default.png
  website:http://hr team coordinator",
    "
  [QBUUser]:
  ID:26229973
  created at:2017-04-11 13:00:53 +0000
  updated at:2018-01-24 08:04:12 +0000
  externalUserID:0
  blobID:0
  facebookID:(null)
  twitterID:(null)
  twitterDigitsID:(null)
  full name:dalila  isabelle   safir
  email:[email protected]
  login:9937
  phone:2
  tags:(null)
  lastRequestAt:2018-01-24 08:04:12 +0000
  customData:default.png
  website:http://human resources director",
    "
  [QBUUser]:
  ID:26429684
  created at:2017-04-16 06:42:44 +0000
  updated at:2018-01-22 11:01:24 +0000
  externalUserID:0
  blobID:0
  facebookID:(null)
  twitterID:(null)
  twitterDigitsID:(null)
  full name:fawaz al  omran
  email:[email protected]
  login:9129
  phone:3
  tags:(null)
  lastRequestAt:2018-01-22 11:01:24 +0000
  customData:default.png
  website:http://brand manager - vimto cordial",
    "
  [QBUUser]:
  ID:26472195
  created at:2017-04-17 06:24:44 +0000
  updated at:2018-01-23 08:22:06 +0000
  externalUserID:0
  blobID:0
  facebookID:(null)
  twitterID:(null)
  twitterDigitsID:(null)
  full name:ahmet  kursat  kaymaz
  email:[email protected]
  login:9625
  phone:3
  tags:(null)
  lastRequestAt:2018-01-23 08:22:06 +0000
  customData:default.png
  website:http://category manager",

Итак, я хотел получить доступ к полному имени и загрузить его в мой метод табличного представления ex - user.fullname [indexpath.row].. но я не знаю метода для доступа и загрузки всех пользователей в мое табличное представление.

Я попробовал следующий метод и без indexpath.row, поэтому он загружает последнего пользователя только в табличное представление.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return multiCombinedArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //  UserTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"contactUserCell" forIndexPath:indexPath];
    static NSString *cellIdentifier = @"UserTableViewCellIdentifier";
    ChatUserTableViewCell *chatUsersCell = (ChatUserTableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if(chatUsersCell == nil)
    {
        chatUsersCell = [[ChatUserTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }

  //  chatUsersCell.chatUserFullName.text = multiCombinedArray

    for(QBUUser *user in multiCombinedArray)
    {
        chatUsersCell.chatUserFullName.text = [NSString stringWithFormat:@"%@",user.fullName];

    }
  return chatUserCell;
}

Пожалуйста, помогите мне быстро получить доступ к полному имени и загрузить все имя в табличное представление.


person Fido    schedule 24.01.2018    source источник


Ответы (1)


Вам не нужно циклически перебирать multiCombinedArray, доступа с помощью indexPath.row будет достаточно, поэтому

заменить это

for(QBUUser *user in multiCombinedArray)
    {
        chatUsersCell.chatUserFullName.text = [NSString stringWithFormat:@"%@",user.fullName];

    }

этим

   QBUUser * user = multiCombinedArray[indexPath.row];
   chatUsersCell.chatUserFullName.text = [NSString stringWithFormat:@"%@",user.fullName];
person Reinier Melian    schedule 24.01.2018
comment
Спасибо, я пропустил простое решение. - person Fido; 24.01.2018