<commit_before>//
//  ObserverNotificationExtension.swift
//  ClosuresKit
//
//  Created by 卓同学 on 16/4/25.
//  Copyright © 2016年 zhuo. All rights reserved.
//

import Foundation

var CSNotificationHandlersKey = "CSNotificationHandlers"

extension NSObject{
    
    public typealias csNotificationHandler = (notification:NSNotification)->Void
    
    public func cs_addNotificationObserverForName(name aName: String, object anObject: AnyObject?,handler:csNotificationHandler){
        NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(NSObject.notificationHandler(_:)), name: aName, object: anObject)
        csNotificationHandlers[aName]=handler
    }
    
    func notificationHandler(notification:NSNotification){
        if let handler = csNotificationHandlers[notification.name]{
            handler(notification: notification)
        }<commit_msg>add remove observer notification func<commit_after>//
//  ObserverNotificationExtension.swift
//  ClosuresKit
//
//  Created by 卓同学 on 16/4/25.
//  Copyright © 2016年 zhuo. All rights reserved.
//

import Foundation

var CSNotificationHandlersKey = "CSNotificationHandlers"

extension NSObject{
    
    public typealias csNotificationHandler = (notification:NSNotification)->Void
    
    public func cs_addNotificationObserverForName(name aName: String, object anObject: AnyObject?,handler:csNotificationHandler){
        NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(NSObject.notificationHandler(_:)), name: aName, object: anObject)
        csNotificationHandlers[aName]=handler
    }
    
    public func cs_removeNotificationObserverForName(name aName:String){
        NSNotificationCenter.defaultCenter().removeObserver(self, name: aName, object: nil)
    }
    
    func notificationHandler(notification:NSNotification){
        if let handler = csNotificationHandlers[notification.name]{
            handler(notification: notification)
        }
{'fraction_non_alphanumeric': 0.08826530612244898, 'fraction_numerical': 0.009183673469387756, 'mean_word_length': 4.3, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2359533', 'n_tokens_mistral': 523, 'n_tokens_neox': 499, 'n_words': 111}