jpsim / JPSVolumeButtonHandler

JPSVolumeButtonHandler provides an easy block interface to hardware volume buttons on iOS devices. Perfect for camera apps!
MIT License
336 stars 91 forks source link

Unable to set nil to the JPSVolumeButtonHandle instance. #38

Closed nrvraghu closed 7 years ago

nrvraghu commented 7 years ago

var volumeButtonHandler = JPSVolumeButtonHandler() and override func viewWillDisappear(_ animated: Bool) { self.volumeButtonHandler = nil //Error showing that Nil can not be assign to the type of "JPSVolumeButtonHandler" } I am using Xcode 8.2.1 version. let me know a solution for this.

CallumOz commented 7 years ago
var volumeButtonHandler: JPSVolumeButtonHandler? = JPSVolumeButtonHandler()

override func viewWillDisappear(_ animated: Bool)
{
    self.volumeButtonHandler = nil
}

Swift variables can only be nil of they have the Optional type, caracterized by the "?" at the declaration:

var volumeButtonHandler: JPSVolumeButtonHandler?