Documentation Archive Developer
Search

CoreMotion Changes for Swift

CoreMotion

Removed CMAttitudeReferenceFrame.init(_: UInt)
Removed CMError.value
Removed CMMagneticFieldCalibrationAccuracy.value
Added CMError.init(rawValue: UInt32)
Added CMError.rawValue
Added CMMagneticFieldCalibrationAccuracy.init(rawValue: Int32)
Added CMMagneticFieldCalibrationAccuracy.rawValue
Added CMSensorRecorder.accelerometerDataFrom(_: NSDate, to: NSDate) -> CMSensorDataList?
Added CMSensorRecorder.recordAccelerometerFor(_: NSTimeInterval)
Modified CMAltimeter
Declaration
From
class CMAltimeter : NSObject {
    class func isRelativeAltitudeAvailable() -> Bool
    func startRelativeAltitudeUpdatesToQueue(_ queue: NSOperationQueue!, withHandler handler: CMAltitudeHandler!)
    func stopRelativeAltitudeUpdates()
}
To
class CMAltimeter : NSObject {
    class func isRelativeAltitudeAvailable() -> Bool
    func startRelativeAltitudeUpdatesToQueue(_ queue: NSOperationQueue, withHandler handler: CMAltitudeHandler)
    func stopRelativeAltitudeUpdates()
}

Declaration
From
func startRelativeAltitudeUpdatesToQueue(_ queue: NSOperationQueue!, withHandler handler: CMAltitudeHandler!)
To
func startRelativeAltitudeUpdatesToQueue(_ queue: NSOperationQueue, withHandler handler: CMAltitudeHandler)

Declaration
From
class CMAltitudeData : CMLogItem {
    var relativeAltitude: NSNumber! { get }
    var pressure: NSNumber! { get }
}
To
class CMAltitudeData : CMLogItem {
    var relativeAltitude: NSNumber { get }
    var pressure: NSNumber { get }
}

Declaration
From
var pressure: NSNumber! { get }
To
var pressure: NSNumber { get }

Declaration
From
var relativeAltitude: NSNumber! { get }
To
var relativeAltitude: NSNumber { get }

Modified CMAttitude
Declaration
From
class CMAttitude : NSObject, NSCopying, NSSecureCoding, NSCoding {
    var roll: Double { get }
    var pitch: Double { get }
    var yaw: Double { get }
    var rotationMatrix: CMRotationMatrix { get }
    var quaternion: CMQuaternion { get }
    func multiplyByInverseOfAttitude(_ attitude: CMAttitude!)
}
To
class CMAttitude : NSObject, NSCopying, NSSecureCoding, NSCoding {
    var roll: Double { get }
    var pitch: Double { get }
    var yaw: Double { get }
    var rotationMatrix: CMRotationMatrix { get }
    var quaternion: CMQuaternion { get }
    func multiplyByInverseOfAttitude(_ attitude: CMAttitude)
}

Declaration
From
func multiplyByInverseOfAttitude(_ attitude: CMAttitude!)
To
func multiplyByInverseOfAttitude(_ attitude: CMAttitude)

DeclarationProtocols
From
struct CMAttitudeReferenceFrame : RawOptionSetType {
    init(_ rawValue: UInt)
    init(rawValue rawValue: UInt)
    static var XArbitraryZVertical: CMAttitudeReferenceFrame { get }
    static var XArbitraryCorrectedZVertical: CMAttitudeReferenceFrame { get }
    static var XMagneticNorthZVertical: CMAttitudeReferenceFrame { get }
    static var XTrueNorthZVertical: CMAttitudeReferenceFrame { get }
}
RawOptionSetType
To
struct CMAttitudeReferenceFrame : OptionSetType {
    init(rawValue rawValue: UInt)
    static var XArbitraryZVertical: CMAttitudeReferenceFrame { get }
    static var XArbitraryCorrectedZVertical: CMAttitudeReferenceFrame { get }
    static var XMagneticNorthZVertical: CMAttitudeReferenceFrame { get }
    static var XTrueNorthZVertical: CMAttitudeReferenceFrame { get }
}
OptionSetType

Declaration
From
class CMDeviceMotion : CMLogItem {
    var attitude: CMAttitude! { get }
    var rotationRate: CMRotationRate { get }
    var gravity: CMAcceleration { get }
    var userAcceleration: CMAcceleration { get }
    var magneticField: CMCalibratedMagneticField { get }
}
To
class CMDeviceMotion : CMLogItem {
    var attitude: CMAttitude { get }
    var rotationRate: CMRotationRate { get }
    var gravity: CMAcceleration { get }
    var userAcceleration: CMAcceleration { get }
    var magneticField: CMCalibratedMagneticField { get }
}

Declaration
From
var attitude: CMAttitude! { get }
To
var attitude: CMAttitude { get }

DeclarationProtocols
From
struct CMError {
    init(_ value: UInt32)
    var value: UInt32
}
--
To
struct CMError : RawRepresentable {
    init(_ rawValue: UInt32)
    init(rawValue rawValue: UInt32)
    var rawValue: UInt32
}
RawRepresentable

DeclarationProtocols
From
struct CMMagneticFieldCalibrationAccuracy {
    init(_ value: Int32)
    var value: Int32
}
--
To
struct CMMagneticFieldCalibrationAccuracy : RawRepresentable {
    init(_ rawValue: Int32)
    init(rawValue rawValue: Int32)
    var rawValue: Int32
}
RawRepresentable

Declaration
From
class CMMotionActivity : CMLogItem {
    var confidence: CMMotionActivityConfidence { get }
    var startDate: NSDate! { get }
    var unknown: Bool { get }
    var stationary: Bool { get }
    var walking: Bool { get }
    var running: Bool { get }
    var automotive: Bool { get }
    var cycling: Bool { get }
}
To
class CMMotionActivity : CMLogItem {
    var confidence: CMMotionActivityConfidence { get }
    var startDate: NSDate { get }
    var unknown: Bool { get }
    var stationary: Bool { get }
    var walking: Bool { get }
    var running: Bool { get }
    var automotive: Bool { get }
    var cycling: Bool { get }
}

Declaration
From
var startDate: NSDate! { get }
To
var startDate: NSDate { get }

Raw Value Type
From--
ToInt

Declaration
From
class CMMotionActivityManager : NSObject {
    class func isActivityAvailable() -> Bool
    func queryActivityStartingFromDate(_ start: NSDate!, toDate end: NSDate!, toQueue queue: NSOperationQueue!, withHandler handler: CMMotionActivityQueryHandler!)
    func startActivityUpdatesToQueue(_ queue: NSOperationQueue!, withHandler handler: CMMotionActivityHandler!)
    func stopActivityUpdates()
}
To
class CMMotionActivityManager : NSObject {
    class func isActivityAvailable() -> Bool
    func queryActivityStartingFromDate(_ start: NSDate, toDate end: NSDate, toQueue queue: NSOperationQueue, withHandler handler: CMMotionActivityQueryHandler)
    func startActivityUpdatesToQueue(_ queue: NSOperationQueue, withHandler handler: CMMotionActivityHandler)
    func stopActivityUpdates()
}

Declaration
From
func queryActivityStartingFromDate(_ start: NSDate!, toDate end: NSDate!, toQueue queue: NSOperationQueue!, withHandler handler: CMMotionActivityQueryHandler!)
To
func queryActivityStartingFromDate(_ start: NSDate, toDate end: NSDate, toQueue queue: NSOperationQueue, withHandler handler: CMMotionActivityQueryHandler)

Declaration
From
func startActivityUpdatesToQueue(_ queue: NSOperationQueue!, withHandler handler: CMMotionActivityHandler!)
To
func startActivityUpdatesToQueue(_ queue: NSOperationQueue, withHandler handler: CMMotionActivityHandler)

Declaration
From
class CMMotionManager : NSObject {
    var accelerometerUpdateInterval: NSTimeInterval
    var accelerometerAvailable: Bool { get }
    var accelerometerActive: Bool { get }
    var accelerometerData: CMAccelerometerData! { get }
    func startAccelerometerUpdates()
    func startAccelerometerUpdatesToQueue(_ queue: NSOperationQueue!, withHandler handler: CMAccelerometerHandler!)
    func stopAccelerometerUpdates()
    var gyroUpdateInterval: NSTimeInterval
    var gyroAvailable: Bool { get }
    var gyroActive: Bool { get }
    var gyroData: CMGyroData! { get }
    func startGyroUpdates()
    func startGyroUpdatesToQueue(_ queue: NSOperationQueue!, withHandler handler: CMGyroHandler!)
    func stopGyroUpdates()
    var magnetometerUpdateInterval: NSTimeInterval
    var magnetometerAvailable: Bool { get }
    var magnetometerActive: Bool { get }
    var magnetometerData: CMMagnetometerData! { get }
    func startMagnetometerUpdates()
    func startMagnetometerUpdatesToQueue(_ queue: NSOperationQueue!, withHandler handler: CMMagnetometerHandler!)
    func stopMagnetometerUpdates()
    var deviceMotionUpdateInterval: NSTimeInterval
    class func availableAttitudeReferenceFrames() -> CMAttitudeReferenceFrame
    var attitudeReferenceFrame: CMAttitudeReferenceFrame { get }
    var deviceMotionAvailable: Bool { get }
    var deviceMotionActive: Bool { get }
    var deviceMotion: CMDeviceMotion! { get }
    func startDeviceMotionUpdates()
    func startDeviceMotionUpdatesToQueue(_ queue: NSOperationQueue!, withHandler handler: CMDeviceMotionHandler!)
    func startDeviceMotionUpdatesUsingReferenceFrame(_ referenceFrame: CMAttitudeReferenceFrame)
    func startDeviceMotionUpdatesUsingReferenceFrame(_ referenceFrame: CMAttitudeReferenceFrame, toQueue queue: NSOperationQueue!, withHandler handler: CMDeviceMotionHandler!)
    func stopDeviceMotionUpdates()
    var showsDeviceMovementDisplay: Bool
}
To
class CMMotionManager : NSObject {
    var accelerometerUpdateInterval: NSTimeInterval
    var accelerometerAvailable: Bool { get }
    var accelerometerActive: Bool { get }
    var accelerometerData: CMAccelerometerData? { get }
    func startAccelerometerUpdates()
    func startAccelerometerUpdatesToQueue(_ queue: NSOperationQueue, withHandler handler: CMAccelerometerHandler)
    func stopAccelerometerUpdates()
    var gyroUpdateInterval: NSTimeInterval
    var gyroAvailable: Bool { get }
    var gyroActive: Bool { get }
    var gyroData: CMGyroData? { get }
    func startGyroUpdates()
    func startGyroUpdatesToQueue(_ queue: NSOperationQueue, withHandler handler: CMGyroHandler)
    func stopGyroUpdates()
    var magnetometerUpdateInterval: NSTimeInterval
    var magnetometerAvailable: Bool { get }
    var magnetometerActive: Bool { get }
    var magnetometerData: CMMagnetometerData? { get }
    func startMagnetometerUpdates()
    func startMagnetometerUpdatesToQueue(_ queue: NSOperationQueue, withHandler handler: CMMagnetometerHandler)
    func stopMagnetometerUpdates()
    var deviceMotionUpdateInterval: NSTimeInterval
    class func availableAttitudeReferenceFrames() -> CMAttitudeReferenceFrame
    var attitudeReferenceFrame: CMAttitudeReferenceFrame { get }
    var deviceMotionAvailable: Bool { get }
    var deviceMotionActive: Bool { get }
    var deviceMotion: CMDeviceMotion? { get }
    func startDeviceMotionUpdates()
    func startDeviceMotionUpdatesToQueue(_ queue: NSOperationQueue, withHandler handler: CMDeviceMotionHandler)
    func startDeviceMotionUpdatesUsingReferenceFrame(_ referenceFrame: CMAttitudeReferenceFrame)
    func startDeviceMotionUpdatesUsingReferenceFrame(_ referenceFrame: CMAttitudeReferenceFrame, toQueue queue: NSOperationQueue, withHandler handler: CMDeviceMotionHandler)
    func stopDeviceMotionUpdates()
    var showsDeviceMovementDisplay: Bool
}

Declaration
From
var accelerometerData: CMAccelerometerData! { get }
To
var accelerometerData: CMAccelerometerData? { get }

Declaration
From
var deviceMotion: CMDeviceMotion! { get }
To
var deviceMotion: CMDeviceMotion? { get }

Declaration
From
var gyroData: CMGyroData! { get }
To
var gyroData: CMGyroData? { get }

Declaration
From
var magnetometerData: CMMagnetometerData! { get }
To
var magnetometerData: CMMagnetometerData? { get }

Declaration
From
func startAccelerometerUpdatesToQueue(_ queue: NSOperationQueue!, withHandler handler: CMAccelerometerHandler!)
To
func startAccelerometerUpdatesToQueue(_ queue: NSOperationQueue, withHandler handler: CMAccelerometerHandler)

Declaration
From
func startDeviceMotionUpdatesToQueue(_ queue: NSOperationQueue!, withHandler handler: CMDeviceMotionHandler!)
To
func startDeviceMotionUpdatesToQueue(_ queue: NSOperationQueue, withHandler handler: CMDeviceMotionHandler)

Declaration
From
func startDeviceMotionUpdatesUsingReferenceFrame(_ referenceFrame: CMAttitudeReferenceFrame, toQueue queue: NSOperationQueue!, withHandler handler: CMDeviceMotionHandler!)
To
func startDeviceMotionUpdatesUsingReferenceFrame(_ referenceFrame: CMAttitudeReferenceFrame, toQueue queue: NSOperationQueue, withHandler handler: CMDeviceMotionHandler)

Declaration
From
func startGyroUpdatesToQueue(_ queue: NSOperationQueue!, withHandler handler: CMGyroHandler!)
To
func startGyroUpdatesToQueue(_ queue: NSOperationQueue, withHandler handler: CMGyroHandler)

Declaration
From
func startMagnetometerUpdatesToQueue(_ queue: NSOperationQueue!, withHandler handler: CMMagnetometerHandler!)
To
func startMagnetometerUpdatesToQueue(_ queue: NSOperationQueue, withHandler handler: CMMagnetometerHandler)

Modified CMPedometer
Declaration
From
class CMPedometer : NSObject {
    class func isStepCountingAvailable() -> Bool
    class func isDistanceAvailable() -> Bool
    class func isFloorCountingAvailable() -> Bool
    func queryPedometerDataFromDate(_ start: NSDate!, toDate end: NSDate!, withHandler handler: CMPedometerHandler!)
    func startPedometerUpdatesFromDate(_ start: NSDate!, withHandler handler: CMPedometerHandler!)
    func stopPedometerUpdates()
}
To
class CMPedometer : NSObject {
    class func isStepCountingAvailable() -> Bool
    class func isDistanceAvailable() -> Bool
    class func isFloorCountingAvailable() -> Bool
    class func isPaceAvailable() -> Bool
    class func isCadenceAvailable() -> Bool
    func queryPedometerDataFromDate(_ start: NSDate, toDate end: NSDate, withHandler handler: CMPedometerHandler)
    func startPedometerUpdatesFromDate(_ start: NSDate, withHandler handler: CMPedometerHandler)
    func stopPedometerUpdates()
}

Declaration
From
func queryPedometerDataFromDate(_ start: NSDate!, toDate end: NSDate!, withHandler handler: CMPedometerHandler!)
To
func queryPedometerDataFromDate(_ start: NSDate, toDate end: NSDate, withHandler handler: CMPedometerHandler)

Declaration
From
func startPedometerUpdatesFromDate(_ start: NSDate!, withHandler handler: CMPedometerHandler!)
To
func startPedometerUpdatesFromDate(_ start: NSDate, withHandler handler: CMPedometerHandler)

Declaration
From
class CMPedometerData : NSObject, NSSecureCoding, NSCoding, NSCopying {
    var startDate: NSDate! { get }
    var endDate: NSDate! { get }
    var numberOfSteps: NSNumber! { get }
    var distance: NSNumber! { get }
    var floorsAscended: NSNumber! { get }
    var floorsDescended: NSNumber! { get }
}
To
class CMPedometerData : NSObject, NSSecureCoding, NSCoding, NSCopying {
    var startDate: NSDate { get }
    var endDate: NSDate { get }
    var numberOfSteps: NSNumber { get }
    var distance: NSNumber? { get }
    var floorsAscended: NSNumber? { get }
    var floorsDescended: NSNumber? { get }
    var currentPace: NSNumber? { get }
    var currentCadence: NSNumber? { get }
}

Declaration
From
var distance: NSNumber! { get }
To
var distance: NSNumber? { get }

Declaration
From
var endDate: NSDate! { get }
To
var endDate: NSDate { get }

Declaration
From
var floorsAscended: NSNumber! { get }
To
var floorsAscended: NSNumber? { get }

Declaration
From
var floorsDescended: NSNumber! { get }
To
var floorsDescended: NSNumber? { get }

Declaration
From
var numberOfSteps: NSNumber! { get }
To
var numberOfSteps: NSNumber { get }

Declaration
From
var startDate: NSDate! { get }
To
var startDate: NSDate { get }

Modified CMStepCounter
Declaration
From
class CMStepCounter : NSObject {
    class func isStepCountingAvailable() -> Bool
    func queryStepCountStartingFrom(_ start: NSDate!, to end: NSDate!, toQueue queue: NSOperationQueue!, withHandler handler: CMStepQueryHandler!)
    func startStepCountingUpdatesToQueue(_ queue: NSOperationQueue!, updateOn stepCounts: Int, withHandler handler: CMStepUpdateHandler!)
    func stopStepCountingUpdates()
}
To
class CMStepCounter : NSObject {
    class func isStepCountingAvailable() -> Bool
    func queryStepCountStartingFrom(_ start: NSDate, to end: NSDate, toQueue queue: NSOperationQueue, withHandler handler: CMStepQueryHandler)
    func startStepCountingUpdatesToQueue(_ queue: NSOperationQueue, updateOn stepCounts: Int, withHandler handler: CMStepUpdateHandler)
    func stopStepCountingUpdates()
}

Declaration
From
func queryStepCountStartingFrom(_ start: NSDate!, to end: NSDate!, toQueue queue: NSOperationQueue!, withHandler handler: CMStepQueryHandler!)
To
func queryStepCountStartingFrom(_ start: NSDate, to end: NSDate, toQueue queue: NSOperationQueue, withHandler handler: CMStepQueryHandler)

Declaration
From
func startStepCountingUpdatesToQueue(_ queue: NSOperationQueue!, updateOn stepCounts: Int, withHandler handler: CMStepUpdateHandler!)
To
func startStepCountingUpdatesToQueue(_ queue: NSOperationQueue, updateOn stepCounts: Int, withHandler handler: CMStepUpdateHandler)

Declaration
From
typealias CMAccelerometerHandler = (CMAccelerometerData!, NSError!) -> Void
To
typealias CMAccelerometerHandler = (CMAccelerometerData?, NSError?) -> Void

Declaration
From
typealias CMAltitudeHandler = (CMAltitudeData!, NSError!) -> Void
To
typealias CMAltitudeHandler = (CMAltitudeData?, NSError?) -> Void

Declaration
From
typealias CMDeviceMotionHandler = (CMDeviceMotion!, NSError!) -> Void
To
typealias CMDeviceMotionHandler = (CMDeviceMotion?, NSError?) -> Void

Modified CMGyroHandler
Declaration
From
typealias CMGyroHandler = (CMGyroData!, NSError!) -> Void
To
typealias CMGyroHandler = (CMGyroData?, NSError?) -> Void

Declaration
From
typealias CMMagnetometerHandler = (CMMagnetometerData!, NSError!) -> Void
To
typealias CMMagnetometerHandler = (CMMagnetometerData?, NSError?) -> Void

Declaration
From
typealias CMMotionActivityHandler = (CMMotionActivity!) -> Void
To
typealias CMMotionActivityHandler = (CMMotionActivity?) -> Void

Declaration
From
typealias CMMotionActivityQueryHandler = ([AnyObject]!, NSError!) -> Void
To
typealias CMMotionActivityQueryHandler = ([CMMotionActivity]?, NSError?) -> Void

Declaration
From
typealias CMPedometerHandler = (CMPedometerData!, NSError!) -> Void
To
typealias CMPedometerHandler = (CMPedometerData?, NSError?) -> Void

Declaration
From
typealias CMStepQueryHandler = (Int, NSError!) -> Void
To
typealias CMStepQueryHandler = (Int, NSError?) -> Void

Declaration
From
typealias CMStepUpdateHandler = (Int, NSDate!, NSError!) -> Void
To
typealias CMStepUpdateHandler = (Int, NSDate, NSError?) -> Void