处理监听字典不能新增键的问题
This commit is contained in:
parent
d3296c13cd
commit
245b8f69a7
@ -13,7 +13,7 @@
|
||||
@implementation Events
|
||||
|
||||
static NSString* PREFIX = @"com.tencent.trtc.event";
|
||||
static NSDictionary<NSString*,NSMutableOrderedSet<Listener*>*> *events = nil;
|
||||
static NSMutableDictionary<NSString*,NSMutableOrderedSet<Listener*>*> *events = nil;
|
||||
|
||||
+ (void)fireEvent: (NSString*)event{
|
||||
[Events fireEvent: nil];
|
||||
@ -48,13 +48,17 @@ static NSDictionary<NSString*,NSMutableOrderedSet<Listener*>*> *events = nil;
|
||||
|
||||
+ (void)init{
|
||||
if( events == nil){
|
||||
NSMutableOrderedSet* listeners = [[NSMutableOrderedSet alloc] init];
|
||||
events = [[NSDictionary alloc] initWithObjectsAndKeys:listeners,@"com.tencent.trtc.eventuserinfo.update", nil];
|
||||
events = [NSMutableDictionary dictionary];
|
||||
}
|
||||
}
|
||||
+ (NSMutableOrderedSet*) getEventListener: (NSString*)event{
|
||||
[Events init];
|
||||
NSString* key = [[NSString alloc] initWithFormat:@"%@%@", PREFIX, event ];
|
||||
NSMutableOrderedSet* listeners =[events valueForKey:key];
|
||||
if(listeners == nil){
|
||||
listeners = [[NSMutableOrderedSet alloc] init];
|
||||
[events setObject:listeners forKey:key];
|
||||
}
|
||||
return [events valueForKey:key];
|
||||
}
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user