Hi,

Here is a patch to have EtoileFoundation HOM working properly on Mac OS X.

With Cocoa, all collection classes are toll-free bridged with their equivalent CoreFoundation types. The issue is that the instances returned by these collection classes always use the mutable class variant as their superclass. e.g. NSCFDictionary which is returned by NSDictionary (and also NSMutableDictionary) is a subclass of NSMutableDictionary. The same holds for NSArray and other collection classes.

Because of that, you have no way to conclude whether an instance is mutable or not. There is no API in Foundation or CoreFoundation to check the mutability. Even introspection like [[NSDictionary dictionary] respondsToSelector: @selector(setObject:forKey:)] will "wrongly" return YES.

I think +mutableSubclass is also rather complicated and not fully generic, in the sense that the mutable class variant isn't always a subclass (e.g. NSString vs NSMutableString or NSCounted which has no immutable variant class). So I suggest to eliminate +mutableSubclass entirely and replace it with a new abstract method +mutableClass declared with NSObject(Etoile) and overriden in subclasses when that makes sense.

This patch adds +mutableClass to NSObject and all collection classes. It also makes the necessary updates in the HOM code to use this new method.
All tests pass on Mac OS X with it.

Attachment: HOM-mutable-class.patch
Description: Binary data




Cheers,
Quentin.
_______________________________________________
Etoile-dev mailing list
Etoile-dev@gna.org
https://mail.gna.org/listinfo/etoile-dev

Reply via email to