0

これが私がやろうとしていることのサンプルコードです。

func firstFunction() {
    var timer = NSTimer.scheduledTimerWithTimeInterval(0.6, target: self, selector: Selector("secondFunction:"), userInfo: self.data!.getInfo(), repeats: false);
    println("Info: \(timer.userInfo)");
}

func secondFunction(value: Int) {
    println("Called with \(value)");
}

出力は次のとおりです Info: Optional(( 2 ))Called with 140552985344960

############ で呼び出されるも常に変化しています。の代わりに数値を使用しても、出力としてself.data!.getInfo取得Info: Optional(2)され、Called with output は変更されます。渡される値がオプションの値であるため、それが起こっていると考えています。それが問題である場合、どうすればオプションではなくなりますか?

4

1 に答える 1