Skip to content

Commit

Permalink
Use an optional for _displayLink (Fixes #1336)
Browse files Browse the repository at this point in the history
_displayLink might not have been created, i.e. in Interface Builder context.
  • Loading branch information
danielgindi authored Aug 22, 2016
1 parent 2e117e3 commit cee0c80
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Charts/Classes/Animation/Animator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Animator: NSObject

private var _startTimeX: NSTimeInterval = 0.0
private var _startTimeY: NSTimeInterval = 0.0
private var _displayLink: NSUIDisplayLink!
private var _displayLink: NSUIDisplayLink?

private var _durationX: NSTimeInterval = 0.0
private var _durationY: NSTimeInterval = 0.0
Expand All @@ -68,9 +68,9 @@ public class Animator: NSObject

public func stop()
{
if (_displayLink != nil)
if _displayLink != nil
{
_displayLink.removeFromRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
_displayLink?.removeFromRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
_displayLink = nil

_enabledX = false
Expand Down Expand Up @@ -192,10 +192,10 @@ public class Animator: NSObject
// Take care of the first frame if rendering is already scheduled...
updateAnimationPhases(_startTimeX)

if (_enabledX || _enabledY)
if _enabledX || _enabledY
{
_displayLink = NSUIDisplayLink(target: self, selector: #selector(animationLoop))
_displayLink.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
_displayLink?.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
}
}

Expand Down Expand Up @@ -258,10 +258,10 @@ public class Animator: NSObject

if (_enabledX || _enabledY)
{
if _displayLink === nil
if _displayLink == nil
{
_displayLink = NSUIDisplayLink(target: self, selector: #selector(animationLoop))
_displayLink.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
_displayLink?.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
}
}
}
Expand Down Expand Up @@ -302,10 +302,10 @@ public class Animator: NSObject

if (_enabledX || _enabledY)
{
if _displayLink === nil
if _displayLink == nil
{
_displayLink = NSUIDisplayLink(target: self, selector: #selector(animationLoop))
_displayLink.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
_displayLink?.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
}
}
}
Expand Down

0 comments on commit cee0c80

Please sign in to comment.