/AppKit/Cib/CPCibBindingConnector.j

http://github.com/cacaodev/cappuccino · Unknown · 62 lines · 53 code · 9 blank · 0 comment · 0 complexity · 421994e08d4e59231a4d6dafedcc39f1 MD5 · raw file

  1. /*
  2. * CPCibBindingConnector.j
  3. * AppKit
  4. *
  5. * Created by Ross Boucher.
  6. * Copyright 2010, 280 North, Inc.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. @import "CPCibConnector.j"
  23. var CPCibBindingConnectorBindingKey = @"CPCibBindingConnectorBindingKey",
  24. CPCibBindingConnectorKeyPathKey = @"CPCibBindingConnectorKeyPathKey",
  25. CPCibBindingConnectorOptionsKey = @"CPCibBindingConnectorOptionsKey";
  26. @implementation CPCibBindingConnector : CPCibConnector
  27. {
  28. id _binding;
  29. id _keyPath;
  30. id _options;
  31. }
  32. - (id)initWithCoder:(CPCoder)aCoder
  33. {
  34. if (self = [super initWithCoder:aCoder])
  35. {
  36. _binding = [aCoder decodeObjectForKey:CPCibBindingConnectorBindingKey];
  37. _keyPath = [aCoder decodeObjectForKey:CPCibBindingConnectorKeyPathKey];
  38. _options = [aCoder decodeObjectForKey:CPCibBindingConnectorOptionsKey];
  39. }
  40. return self;
  41. }
  42. - (void)encodeWithCoder:(CPCoder)aCoder
  43. {
  44. [super encodeWithCoder:aCoder];
  45. [aCoder encodeObject:_binding forKey:CPCibBindingConnectorBindingKey];
  46. [aCoder encodeObject:_keyPath forKey:CPCibBindingConnectorKeyPathKey];
  47. [aCoder encodeObject:_options forKey:CPCibBindingConnectorOptionsKey];
  48. }
  49. - (void)establishConnection
  50. {
  51. [_source bind:_binding toObject:_destination withKeyPath:_keyPath options:_options];
  52. }
  53. @end