mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-01 22:56:17 +00:00
Restored KVO exception, added mutating operations to test app
This commit is contained in:
@@ -775,7 +775,7 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOpti
|
||||
else
|
||||
{
|
||||
if (!changes)
|
||||
return;
|
||||
[CPException raise:@"CPKeyValueObservingException" reason:@"'didChange...' message called without prior call of 'willChange...'"];
|
||||
|
||||
[changes removeObjectForKey:CPKeyValueChangeNotificationIsPriorKey];
|
||||
|
||||
|
||||
@@ -78,6 +78,27 @@
|
||||
[contentView addSubview:employeesScrollView];
|
||||
[contentView addSubview:text];
|
||||
|
||||
var button = [CPButton buttonWithTitle:@"Add Item"];
|
||||
|
||||
[button setFrameOrigin:CGPointMake(500, 30)];
|
||||
[button setTarget:self];
|
||||
[button setAction:@selector(addItem:)];
|
||||
[contentView addSubview:button];
|
||||
|
||||
button = [CPButton buttonWithTitle:@"Insert Item"];
|
||||
|
||||
[button setFrameOrigin:CGPointMake(500, 70)];
|
||||
[button setTarget:self];
|
||||
[button setAction:@selector(insertItem:)];
|
||||
[contentView addSubview:button];
|
||||
|
||||
button = [CPButton buttonWithTitle:@"Remove Item"];
|
||||
|
||||
[button setFrameOrigin:CGPointMake(500, 110)];
|
||||
[button setTarget:self];
|
||||
[button setAction:@selector(removeItem:)];
|
||||
[contentView addSubview:button];
|
||||
|
||||
companiesController = [CPArrayController new];
|
||||
[companiesController bind:@"contentArray" toObject:companies withKeyPath:@"items" options:nil];
|
||||
|
||||
@@ -108,4 +129,24 @@
|
||||
console.log("\nkeyPath: %s\ncontext: %s\nnew: %s\nold: %s", keyPath, context, [[change valueForKey:CPKeyValueChangeNewKey] description], [[change valueForKey:CPKeyValueChangeOldKey] description]);
|
||||
}
|
||||
|
||||
- (void)addItem:(id)sender
|
||||
{
|
||||
var item = [CPDictionary dictionaryWithObjectsAndKeys:@"Seven Dwarves", @"name", [CPArray arrayWithObjects:@"Sneezy", @"Dopey", @"Sleepy", @"Doc", @"Bashful", @"Happy", @"Grumpy"], @"employees"];
|
||||
|
||||
[companiesController addObject:item];
|
||||
}
|
||||
|
||||
- (void)insertItem:(id)sender
|
||||
{
|
||||
var item = [CPDictionary dictionaryWithObjectsAndKeys:@"Acme Corp", @"name", [CPArray arrayWithObjects:@"Road Runner", @"Wile E. Coyote"], @"employees"];
|
||||
|
||||
[companiesController insertObject:item atArrangedObjectIndex:1];
|
||||
}
|
||||
|
||||
- (void)removeItem:(id)sender
|
||||
{
|
||||
if ([[companiesController arrangedObjects] count])
|
||||
[companiesController removeObjectAtArrangedObjectIndex:0];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user