Search code examples
iosswiftgoogle-analyticstry-catchgoogle-analytics-firebase

When adding do,try catch Google Analytic tracker got error


I still can't figure my simple do,try catch at json parsing causing google analytic compile time error.

Especially at theses :

let tracker = GAI.sharedInstance().defaultTracker
let event = GAIDictionaryBuilder.createEventWithCategory("Home Screen", action: "Tapped", label: "User tapped one of content from Home Content Area 2", value: nil)
tracker.send(event.build() as [NSObject : AnyObject]) // Show me error at this

enter image description here

All I did was adding my do,try catch at RequestSuccess[When getting response from server,parse json to model object] delegate method.

Any Help,do I need to add some info extras?

When I remove do,try,catch,that error gone.Do my do,try,catch concern with that error?


Solution

  • It's not obvious, but I don't think the do, try, catch is the issue. Try:

    tracker.send(event!.build() as [NSObject : AnyObject])
    

    You may also need to unwrap the tracker with tracker?.send... etc.