2017-10-23 11 views
0

ファブリックを使用してイベントを追跡したい。これはファブリックを使用してイベントを追跡する方法

import Answers 
    func trackEvent() { 

    Answers.logCustomEvent(withName: "testEvent", customAttributes: ["Category":"test", "Player":50]) 
} 

を使用して経由して私のために働いているしかし、私は、私はすべてのイベントを追跡する必要があるすべてのビューに答えクラスをインポートする必要があります。回答クラスを毎回インポートせずにイベントを追跡する方法や方法はありますか?

答えて

1

これはいかがですか?クラスを作成してTrackerと入力し、Answersをインポートします。

import Answers 
class Tracker { 
    static func logCustomEvent(withName:String, customAttributes:[String:Any]) { 
     Answers.logCustomEvent(withName: withName, customAttributes: customAttributes) 
    } 
} 

次に、何もインポートせずにクラスを使用します。

Tracker.logCustomEvent(withName: "testEvent", customAttributes: ["Category":"test", "Player":50]) 
関連する問題