我正在开发一个聊天应用程序。我的一些类是单例,因此我使用了很多静态方法。
在app delegate中收到新消息时。它应该将它发送到我的incomingChat viewController。
我能够在viewcontroller中获取静态方法的新消息。但我不能从静态方法重新加载表。
InCommingVC.h
#import <UIKit/UIKit.h>
@interface InCommingVC : UIViewController
@property (weak, nonatomic) IBOutlet UINavigationBar *navigationBarTitle;
@property (weak, nonatomic) IBOutlet UITableView *incommingTable;
+ (void) sendIncommingChats:(NSDictionary *) chatDetails;
+ (void) recieveIncomingChat:(NSDictionary *) chatDetails;
@end
InCommingVC.m
#import "InCommingVC.h"
#import "AppDelegate.h"
#import "IncommingItemObject.h"
static NSMutableArray *incomminglist;
@interface InCommingVC (){
AppDelegate *delegate;
}
@end
@implementation InCommingVC
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationBarTitle.topItem.title = @"Incomming Chats";
}
+ (void) recieveIncomingChat:(NSDictionary *) chatDetails{
NSLog(@"GOT A NEW recieveIncomingChat");
NSString *CompanyId = [chatDetails objectForKey:@"CompanyId"];
NSString *ConnectionId = [chatDetails objectForKey:@"ConnectionId"];
NSString *CountryCode = [chatDetails objectForKey:@"CountryCode"];
NSString *Department = [chatDetails objectForKey:@"Department"];
NSString *Name = [chatDetails objectForKey:@"Name"];
NSString *StartTime = [chatDetails objectForKey:@"StartTime"];
NSString *TimeZone = [chatDetails objectForKey:@"TimeZone"];
NSString *VisitorID = [chatDetails objectForKey:@"VisitorID"];
NSString *WidgetId = [chatDetails objectForKey:@"WidgetId"];
NSLog(@"------------------------------------------------------------------------------");
NSLog(@"CompanyId : %@" , CompanyId);
NSLog(@"ConnectionId : %@" , ConnectionId);
NSLog(@"CountryCode : %@" , CountryCode);
NSLog(@"Department : %@" , Department);
NSLog(@"Name : %@" , Name);
NSLog(@"StartTime : %@" , StartTime);
NSLog(@"TimeZone : %@" , TimeZone);
NSLog(@"VisitorID : %@" , VisitorID);
NSLog(@"WidgetId : %@" , WidgetId);
NSLog(@"------------------------------------------------------------------------------");
IncommingItemObject *item = [[IncommingItemObject alloc] init];
[item setCompanyId:CompanyId];
[item setConnectionId:ConnectionId];
[item setCountryCode:CountryCode];
[item setDepartment:Department];
[item setName:Name];
[item setStartTime:StartTime];
[item setTimeZone:TimeZone];
[item setVisitorID:VisitorID];
[item setWidgetId:WidgetId];
if (incomminglist.count == 0) {
incomminglist = [[NSMutableArray alloc] init];
[incomminglist addObject:item];
[[InCommingVC incommingTable] reloadData];
} else {
[incomminglist addObject:item];
}
NSLog(@"count %i", incomminglist.count);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return incomminglist.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellIdentifier = @"identify_incomming";
UITableViewCell *cell = [self.incommingTable dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
IncommingItemObject *item = [incomminglist objectAtIndex:indexPath.row];
UIImageView *CountryImage = (UIImageView *)[cell viewWithTag:5010];
[CountryImage setImage:[UIImage imageNamed:item.CountryCode]];
UILabel *visitorName = (UILabel *)[cell viewWithTag:5011];
visitorName.text = item.Name;
UILabel *visitStartTime = (UILabel *)[cell viewWithTag:5012];
visitStartTime.text = item.StartTime;
return cell;
}
我想从静态方法更新incommingTable
。有人能帮我吗。 TNX。
我有这个错误
/ Users / zupportdesk / Desktop / MyIOSApps / Chat System / Chat System / InCommingVC.m:96:23:选择器没有已知的类方法 &#39; incommingTable&#39;
做着
[[InCommingVC incommingTable] reloadData];
答案 0 :(得分:1)
2种方式:
1 - 制作共享实例。致电:
[[[self class] sharedInstance].tableView reloadData];
2 - 让您上课确认一些通知,您将在收到有效负载消息(聊天词典)后发送。确保在视图控制器取消分配
时取消注册通知答案 1 :(得分:0)
SELECT ufs.tablespace_name ,(SUM(bytes) /(1024*1024)) AS FREESPACE
FROM user_free_space ufs
WHERE EXISTS
(SELECT DISTINCT tablespace_name
FROM all_tables
WHERE tablespace_name IS NOT NULL
AND ufs.tablespace_name = tablespace_name
AND tablespace_name =
(SELECT DEFAULT_TABLESPACE FROM USER_USERS WHERE USERNAME ='USER1'
)
)
GROUP BY tablespace_name;
请尝试这一点并确保IBOUTLET正确连接