this questionが見つかりました。コードをXcodeプロジェクトにコピーしようとしましたが、次のエラーメッセージが表示されます。NSTimerを使用した繰り返し機能が失敗しました:
error: use of unresolved identifier 'self'
正しい方法はありますか?
編集:ここでは遊び場でテストコード、:通常のプロパティに大文字を使用して
//: Playground - noun: a place where people can play
import Cocoa
import Foundation
func sayHello() {
print("hello World")
}
var SwiftTimer = NSTimer()
SwiftTimer = NSTimer.scheduledTimerWithTimeInterval(1, target:self, selector: Selector("sayHello"), userInfo: nil, repeats: true)
プロジェクトの一部のコードを投稿 –
@AlessandroOrnano私は質問を編集しました – HelloToYou