From df2be926a59a11ca0d8d65414afd41357734ea0d Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Thu, 24 Oct 2013 18:59:19 +0200 Subject: [PATCH] Fixed: Return a Number from CPNumber>>numberWithBool: The Cocoa signature for this method + (NSNumber *)numberWithBool:(BOOL)value implies that a number is being returned. In Cappuccino a Boolean is returned. This leads to some problems e.g. in addObserver:forKeyPath:options:context: with CPKeyValueObservingOptionPrior and observeValueForKeyPath:ofObject:change:context: with CPKeyValueObservingOptionPrior. Setting CPKeyValueObservingOptionPrior leads to CPKeyValueChangeNotificationIsPriorKey being set to 1 (which should be equal to [NSNumber numberWithBool:YES] as documented in https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Protocols/NSKeyValueObserving_Protocol/Reference/Reference.html. The actual value though is true as [CPNumber numberWithBool:YES] does not return a number but a boolean. This commit fixes this issue. --- Foundation/CPNumber.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Foundation/CPNumber.j b/Foundation/CPNumber.j index 9bf54323c..33bcb73ac 100644 --- a/Foundation/CPNumber.j +++ b/Foundation/CPNumber.j @@ -50,7 +50,7 @@ var CPNumberUIDs = new CFMutableDictionary(); + (id)numberWithBool:(BOOL)aBoolean { - return aBoolean; + return aBoolean ? 1 : 0; } + (id)numberWithChar:(char)aChar