[英]How to Access an Object from a Data model (NSobject) based NSArray?
I have an Array which executed and combined multiple QBUUser users below. 我有一个执行和合并以下多个QBUUser用户的数组。
2018-01-24 12:05:33.095197+0400 samplechat[70177:6634702] COMBINEDARRAY( 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:rothessa.sevilla@aujan.com
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:dalila.safir@aujan.com
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:fawaz.alomran@aujan.com
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:kursat.kaymaz@aujan.com
login:9625
phone:3
tags:(null)
lastRequestAt:2018-01-23 08:22:06 +0000
customData:default.png
website:http://category manager",
So I wanted to access the fullname and load into my tableview method ex - user.fullname [indexpath.row].. but I don't know a method to access and load allusers into my table view. 因此,我想访问全名并加载到我的tableview方法中,例如-user.fullname [indexpath.row] ..但我不知道一种访问所有用户并将其加载到我的表视图中的方法。
I tried following method and without indexpath.row so it's loading the last user only to the tableview. 我尝试了以下方法,并且没有indexpath.row,所以它仅将最后一个用户加载到tableview中。
- (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;
}
Please help me quickly to access the fullname and load all name into the table view. 请帮助我快速访问全名并将所有名称加载到表格视图中。
You don't need to cycle over your multiCombinedArray
, accessing with the indexPath.row
will be enough, so 您不需要循环遍历
multiCombinedArray
,使用indexPath.row
进行访问就足够了,因此
replace this 取代这个
for(QBUUser *user in multiCombinedArray)
{
chatUsersCell.chatUserFullName.text = [NSString stringWithFormat:@"%@",user.fullName];
}
by this 这样
QBUUser * user = multiCombinedArray[indexPath.row];
chatUsersCell.chatUserFullName.text = [NSString stringWithFormat:@"%@",user.fullName];
QBUUser * user = multiCombinedArray[indexPath.row];
chatUsersCell.chatUserFullName.text = user.fullName
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.