mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-02 19:22:58 +00:00
Merge pull request #1630 from slevenbits/cparray-fix
Fix CPArray should throw an exception when observer is added/removed.
This commit is contained in:
commit
d0b152c638
1 file changed
+28
@@ -514,6 +514,31 @@
|
||||
|
||||
@implementation CPArray (KeyValueObserving)
|
||||
|
||||
/*!
|
||||
Raises an exception.
|
||||
|
||||
CPArray objects are not observable, so this method raises an exception when invoked on an CPArray object.
|
||||
Instead of observing a array, observe the ordered to-many relationship for which the array is the collection of related objects.
|
||||
*/
|
||||
- (void)addObserver:(id)anObserver forKeyPath:(CPString)aKeyPath options:(CPKeyValueObservingOptions)anOptions context:(id)aContext
|
||||
{
|
||||
[CPException raise:CPInvalidArgumentException reason:"[CPArray " + CPStringFromSelector(_cmd) + "] is not supported. Key path: " + aKeyPath];
|
||||
}
|
||||
|
||||
/*!
|
||||
Raises an exception.
|
||||
|
||||
CPArray objects are not observable, so this method raises an exception when invoked on an CPArray object.
|
||||
Instead of observing a array, observe the ordered to-many relationship for which the array is the collection of related objects.
|
||||
*/
|
||||
- (void)removeObserver:(id)anObserver forKeyPath:(CPString)aKeyPath
|
||||
{
|
||||
[CPException raise:CPInvalidArgumentException reason:"[CPArray " + CPStringFromSelector(_cmd) + "] is not supported. Key path: " + aKeyPath];
|
||||
}
|
||||
|
||||
/*!
|
||||
Registers an observer to receive key value observer notifications for the specified key-path relative to the objects at the indexes.
|
||||
*/
|
||||
- (void)addObserver:(id)anObserver toObjectsAtIndexes:(CPIndexSet)indexes forKeyPath:(CPString)aKeyPath options:(unsigned)options context:(id)context
|
||||
{
|
||||
var index = [indexes firstIndex];
|
||||
@@ -526,6 +551,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes anObserver from all key value observer notifications associated with the specified keyPath relative to the array’s objects at indexes.
|
||||
*/
|
||||
- (void)removeObserver:(id)anObserver fromObjectsAtIndexes:(CPIndexSet)indexes forKeyPath:(CPString)aKeyPath
|
||||
{
|
||||
var index = [indexes firstIndex];
|
||||
|
||||
Reference in new issue
Block a user