Commit d67e4477 authored by 汪洋's avatar 汪洋

重写referrerId的get方法,会自动获取

parent 1a948f13
......@@ -9,5 +9,9 @@
#import <UIKit/UIKit.h>
#import "PhobosPVProtocol.h"
@interface UIResponder (PhobosPV) <PhobosPVProtocol>
/**
只适用于controller自动初始化referer
*/
- (void)initReferer;
@end
......@@ -78,7 +78,21 @@
- (NSString *)referrerId {
NSString *referrerId = objc_getAssociatedObject(self, @selector(referrerId));
return referrerId == nil ? @"" : referrerId;
if (referrerId == nil) {
if ([self isKindOfClass:[UIViewController class]]) {
NSArray *navigationPool = ((UIViewController *)self).navigationController.viewControllers;
NSInteger refererIdIndex = navigationPool.count - 2;
if (refererIdIndex < 0) {
return @"";
} else {
UIViewController *controller = navigationPool[refererIdIndex];
NSString *preBusinessId = controller.businessId;
objc_setAssociatedObject(self, @selector(referrerId), preBusinessId, OBJC_ASSOCIATION_COPY);
return preBusinessId;
}
}
}
return referrerId;
}
- (BOOL)needLogPV {
......
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