【发布时间】:2015-09-05 23:01:02
【问题描述】:
我正在研究一个要点:PasteboardWatcher.swift,我在其中调用了一个 NSTimer 对象,如下所示:
func startPolling () {
// setup and start of timer
timer = NSTimer.scheduledTimerWithTimeInterval(2, target: self, selector: Selector("checkForChangesInPasteboard"), userInfo: nil, repeats: true)
}
checkForChangesInPasteboard 函数的定义是:
func checkForChangesInPasteboard() {
// definition continues..
}
我不想将函数 checkForChangesInPasteboard 暴露给其他类,因此我想将其标记为私有,但由于某种原因,当我这样做时,它会引发以下异常:
-[PasteboardWatcher.PasteboardWatcher checkForChangesInPasteboard]: unrecognized selector sent to instance
如果我不将其标记为私有,它会完美运行。
有什么方法可以让这个方法保持私有,对其他类隐藏它?
【问题讨论】:
标签: swift access-control