I would like to place GA's screen tracking code in a location that is always called (e.g., UIVeiwController) when I view each view, so that I can dynamically get the class name, but where is the code actually correct?
If possible, I would appreciate it if you could provide me with a code that would be a sample.
Thank you for your cooperation.
swift ios
How about creating one parent class and inheriting the others?
class MYBaseViewController:UIViewController
{
override func viewWillAppear (animated:Bool)
{
super.viewWillAppear(animated)
// GA screen tracking code here
}
}
For each class:
class MYViewController:MYBaseViewController
{
override func viewWillAppear (animated:Bool)
{
super.viewWillAppear(animated)// Don't forget this.
// Write the code as usual
}
}
If you implement it with extension, it will be like adding a method, so
I think it's still something you have to call manually.
© 2024 OneMinuteCode. All rights reserved.