let performer = NSHapticFeedbackManager.defaultPerformer
performer.perform(.generic, performanceTime: .now)
NSHapticFeedbackPatterns
NSHapticFeedbackPatternsIs used to specify the type of tactile feedback, it takes one of the following values.
.LevelChange
.Alignment
.Generic
.LevelChangeIt is, if the user has changed the strength to press the track pad, used to feedback it. For example, if there is a button to accept the strength of the two-step, you will need to feed it back to the user when the user switches to the second stage from the first stage, but you specify this in such instances.
.AlignmentIt is used to perform the guide when the user or to resize or move the object. For example, you can get a tactile feedback, such as stick to grid when performing an operation of the control when the xib editor Xcode operating in Force Touch trackpad, similar to that of the implementation in the application as If you are to specify this.
.GenericIt is specified in case that does not apply to the above example.
NSHapticFeedbackPerformanceTime
NSHapticFeedbackPerformanceTimeSpecifies the timing at which the tactile feedback. .NowMake the feedback at the same time as the specified call and the but, .DrawCompletedfor leaving be delayed if you specify so far drawing complete, you can use both depending on the characteristics of the view.
Example
import Cocoa
let performer = NSHapticFeedbackManager.defaultPerformer()
for _ in 0..<10 {
performer.performFeedbackPattern(.Alignment, performanceTime: .Now)
sleep(1)
performer.performFeedbackPattern(.LevelChange, performanceTime: .Now)
sleep(1)
performer.performFeedbackPattern(.Generic, performanceTime: .Now)
sleep(1)
}