Commit 1b927ed3 authored by 汪洋's avatar 汪洋

优化visibleController的获取方式

parent 7e1bb3f5
......@@ -76,6 +76,12 @@
数据接收的服务器API
*/
@property (copy, nonatomic) NSString *serverAPI;
/**
从主项目获取当前显示的controller
*/
@property (nonatomic, copy) UIViewController * (^getTopController) (void);
#pragma mark - 事件采集
/**
......
......@@ -130,15 +130,7 @@ static NSString *sdkVersion = @"110";
}
- (UIViewController *)visibleController {
id target = [UIApplication sharedApplication].keyWindow.rootViewController;
if ([target isKindOfClass:[UITabBarController class]]) {
UITabBarController *tabbar = (UITabBarController *)target;
UINavigationController *navigationController = (UINavigationController *)tabbar.selectedViewController;
target = navigationController.visibleViewController;
} else if ([target isKindOfClass:[UINavigationController class]]) {
UINavigationController *navigationController = (UINavigationController *)target;
target = navigationController.visibleViewController;
}
id target = self.getTopController();
if ([target conformsToProtocol:NSProtocolFromString(@"PhobosCustomVisibleController")]) {
target = [target performSelector:@selector(phobosVisibleController)];
......@@ -439,7 +431,9 @@ static NSString *sdkVersion = @"110";
- (void)sendArray {
NSMutableArray *dataArray = [[WMCacheService sharedInstance] fetchObjectAtDucmentPathWithkey:PhobosTempCacheKey];
if (_logEnabled) {
phobosLog([NSString stringWithFormat:@"array prepare to fly --✈: %@",dataArray]);
NSData *data = [NSJSONSerialization dataWithJSONObject:dataArray options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
phobosLog([NSString stringWithFormat:@"array prepare to fly --✈: %@", jsonString]);
}
@try {
NSData *JSON = [PhobosUtil encodeJSON:dataArray];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment