unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

ChangeNotifier.swift (926B)

      1 //
      2 //  ChangeNotifier.swift
      3 //  UnrealIRCd
      4 //
      5 //  Created by Travis McArthur on 7/19/15.
      6 //  Copyright (c) 2015 UnrealIRCd Team. All rights reserved.
      7 //
      8 
      9 import Foundation
     10 class ChangeNotifier {
     11     
     12     var changeDelegates : Array<ChangeNotifierDelegate> = []
     13     
     14     init()
     15     {
     16         
     17     }
     18     
     19     func attachChangeDelegate(delegate: ChangeNotifierDelegate)
     20     {
     21         changeDelegates.append(delegate)
     22     }
     23     
     24     func dettachChangeDelegate(delegate: ChangeNotifierDelegate)
     25     {
     26         for i in 0 ... changeDelegates.count
     27         {
     28             if changeDelegates[i] === delegate
     29             {
     30                 changeDelegates.removeAtIndex(i)
     31             }
     32         }
     33     }
     34         func notifyListeners()
     35     {
     36         for listener in changeDelegates
     37         {
     38             listener.modelChanged(self)
     39         }
     40     }
     41 }
     42 
     43 protocol ChangeNotifierDelegate : class
     44 {
     45     func modelChanged(model: ChangeNotifier);
     46 }