作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我希望这个库不是扩展我所有的类,而是扩展到所有类
@interface ViewController : GAITrackedViewController
最佳答案
您不应该在每个类中扩展它。您只需要在您的 appDelegate 中注册您的 GAITracker
,然后从您的 viewController 中向它发送事件。它是一个单例,所以你所要做的就是导入它并在你想要从中发送事件的每个 viewController 中调用你的 defaultTracker。
在 AppDelegate.m 中的 application:didFinishLaunchingWithOptions:
中:
GAI sharedInstance].trackUncaughtExceptions = YES;
[GAI sharedInstance].dispatchInterval = 120;
[GAI sharedInstance].debug = NO;
id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"yourID"];
然后在您想要跟踪事件的每个 viewController 中,只需执行以下操作:
[[GAI sharedInstance].defaultTracker sendEventWithCategory:@"yourViewControllerName" withAction:@"somethingHappened" withLabel:@"yourLabel" withValue:@1];
关于ios - 如何在 ios 中使用 google Analytics,而无需在所有库中扩展库 GAY Tracked ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18091851/
我是一名优秀的程序员,十分优秀!