修复了数组可能越界的问题
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#import "XPMacro.h"
|
||||
#import "UITableView+NIMScrollToBottom.h"
|
||||
#import "ThemeColor.h"
|
||||
#import "NSArray+Safe.h"
|
||||
///Model
|
||||
#import "RoomInfoModel.h"
|
||||
#import "UserInfoModel.h"
|
||||
@@ -115,7 +116,7 @@
|
||||
[self.sessionTableView.mj_header endRefreshing];
|
||||
if (error == nil && messages.count > 0) {
|
||||
for (int i = ((int)messages.count -1); i > 0; i--) {
|
||||
NIMMessage * message = [messages objectAtIndex:i];
|
||||
NIMMessage * message = [messages safeObjectAtIndex1:i];
|
||||
[self.messages insertObject:message atIndex:0];
|
||||
}
|
||||
}
|
||||
@@ -350,7 +351,7 @@
|
||||
}
|
||||
|
||||
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
|
||||
NIMMessage * message = [self.messages objectAtIndex:indexPath.row];
|
||||
NIMMessage * message = [self.messages safeObjectAtIndex1:indexPath.row];
|
||||
NSString * identifier = [MessageCell cellContent:message];
|
||||
///从复用池中获取所需要的cell
|
||||
MessageCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
|
||||
@@ -361,12 +362,12 @@
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:identifier];
|
||||
}
|
||||
cell.delegate = self;
|
||||
[cell renderWithMessage:[self.messages objectAtIndex:indexPath.row]];
|
||||
[cell renderWithMessage:[self.messages safeObjectAtIndex1:indexPath.row]];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
NIMMessage *msg = [self.messages objectAtIndex:indexPath.row];
|
||||
NIMMessage *msg = [self.messages safeObjectAtIndex1:indexPath.row];
|
||||
return [MessageCell measureHeight:msg];
|
||||
}
|
||||
|
||||
@@ -498,7 +499,7 @@
|
||||
|
||||
UIWindow * currentWindow;
|
||||
for (int i = 0; i < [UIApplication sharedApplication].windows.count; i++) {
|
||||
UIWindow * window = [[UIApplication sharedApplication].windows objectAtIndex:i];
|
||||
UIWindow * window = [[UIApplication sharedApplication].windows safeObjectAtIndex1:i];
|
||||
if(window.tag == 1000) {
|
||||
currentWindow = window;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user