<commit_before>//
//  CAAnimation+Closure.swift
//  CAAnimation+Closures
//
//  Created by <NAME> on 2/5/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import QuartzCore

/**
*  CAAnimation Delegation class implementation
*/
class ZHCAAnimationDelegate: NSObject {
    /// start: A block (closure) object to be executed when the animation starts. This block has no return value and takes no argument.
    var start: (() -> Void)?
    
    /// completion: A block (closure) object to be executed when the animation ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished.
    var completion: ((Bool) -> Void)?
    
    /**
    Called when the animation begins its active duration.
    
    :param: theAnimation the animation about to start
    */
    override func animationDidStart(theAnimation: CAAnimation) {
        start?()
    }
    
    /**
    Called when the animation completes its active duration or is removed from the object it is attached to.
    
    :param: theAnimation the animation about to end
    :param: finished     A Boolean value indicates whether or not the animations actually finished.
    */
    override func animationDidStop(theAnimation: CAAnimation, finished: Bool) {
        completion?(finished)
    }
}

extension CAAnimation {
    // Add start and completion property for CAAnimation Class
    /// start: A block (closure) object to be executed when the animation starts. This block has no return value and takes no argument.
    var start: (() -> Void)? {
        set {
            if self.delegate == nil || !self.delegate!.isKindOfClass(ZHCAAnimationDelegate) {
                self.delegate = ZHCAAnimationDelegate()
            }
            (self.delegate! as ZHCAAnimationDelegate).start = newValue
        }
        
        get {
            if (self.delegate != nil) && self.delegate.isKindOfClass(ZHCAAnimationDelegate) {
                return (self.delegate as ZHCAAnimationDelegate).start
            }
            return nil
        }
    }
    
    /**
    Convenience method for setting start
    * Use func can have a code auto completion
    
    :param: start start closure
    */
    func setStart(#start: () -> Void) {
        self.start = start
    }
    
    /// completion: A block (closure) object to be executed when the animation ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished.
    var completion: ((Bool) -> Void)? {
        set {
            if self.delegate == nil || !self.delegate!.isKindOfClass(ZHCAAnimationDelegate) {
                self.delegate = ZHCAAnimationDelegate()
            }
            (self.delegate! as ZHCAAnimationDelegate).completion = newValue
        }
        
        get {
            if (self.delegate != nil) && self.delegate!.isKindOfClass(ZHCAAnimationDelegate) {
                return (self.delegate as ZHCAAnimationDelegate).completion
            }
            return nil
        }
    }
    
    /**
    Convenience method for setting completion
    
    :param: completion completion closure
    */
    func setCompletion(completion: ((Bool) -> Void)) {
        self.completion = completion
    }
}

extension CALayer {<commit_msg>Last update for Swift 1.1 (Xcode 6.2)<commit_after>//
//  CAAnimation+Closure.swift
//  CAAnimation+Closures
//
//  Created by <NAME> on 2/5/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import QuartzCore

/**
*  CAAnimation Delegation class implementation
*/
class ZHCAAnimationDelegate: NSObject {
    /// start: A block (closure) object to be executed when the animation starts. This block has no return value and takes no argument.
    var start: (() -> Void)?
    
    /// completion: A block (closure) object to be executed when the animation ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished.
    var completion: ((Bool) -> Void)?
    
    /**
    Called when the animation begins its active duration.
    
    :param: theAnimation the animation about to start
    */
    override func animationDidStart(theAnimation: CAAnimation) {
        start?()
    }
    
    /**
    Called when the animation completes its active duration or is removed from the object it is attached to.
    
    :param: theAnimation the animation about to end
    :param: finished     A Boolean value indicates whether or not the animations actually finished.
    */
    override func animationDidStop(theAnimation: CAAnimation, finished: Bool) {
        completion?(finished)
    }
}

extension CAAnimation {
    // Add start and completion property for CAAnimation Class
    /// start: A block (closure) object to be executed when the animation starts. This block has no return value and takes no argument.
    var start: (() -> Void)? {
        set {
            if self.delegate == nil || !self.delegate!.isKindOfClass(ZHCAAnimationDelegate) {
                self.delegate = ZHCAAnimationDelegate()
            }
            (self.delegate as ZHCAAnimationDelegate).start = newValue
        }
        
        get {
            if (self.delegate != nil) && self.delegate.isKindOfClass(ZHCAAnimationDelegate) {
                return (self.delegate as ZHCAAnimationDelegate).start
            }
            return nil
        }
    }
    
    /**
    Convenience method for setting start
    * Use func can have a code auto completion
    
    :param: start start closure
    */
    func setStart(#start: () -> Void) {
        self.start = start
    }
    
    /// completion: A block (closure) object to be executed when the animation ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished.
    var completion: ((Bool) -> Void)? {
        set {
            if self.delegate == nil || !self.delegate!.isKindOfClass(ZHCAAnimationDelegate) {
                self.delegate = ZHCAAnimationDelegate()
            }
            (self.delegate as ZHCAAnimationDelegate).completion = newValue
        }
        
        get {
            if (self.delegate != nil) && self.delegate!.isKindOfClass(ZHCAAnimationDelegate) {
                return (self.delegate as ZHCAAnimationDelegate).completion
            }
            return nil
        }
    }
    
    /**
    Convenience method for setting completion
    
    :param: completion completion closure
    */
    func setCompletion(completion: ((Bool) -> Void)) {
        self.completion = completion
    }
}

extension CALayer {
{'fraction_non_alphanumeric': 0.08408408408408409, 'fraction_numerical': 0.003003003003003003, 'mean_word_length': 2.3089915548931943, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3593152', 'n_tokens_mistral': 1735, 'n_tokens_neox': 1656, 'n_words': 618}