Re: Initing sublacss with superclass method
Riccardo Mottola <[email protected]> Tue, 22 Jul 2025 13:23:54 +0200
| Newsgroups | gmane.comp.lib.gnustep.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Wolfgang, nice to read you. Wolfgang Lux wrote: > Come on Riccardo, before accusing Apple of lying, you should better check the facts first.:-) well.. I checked what the code does when "compiled" not only the documentation. on 10.13 XCode indeed has: + (NSMutableCharacterSet <apple-reference-documentation://hcbtoad_se>*)characterSetWithCharactersInString:(NSString <apple-reference-documentation://hcdPnFRdoM>*)aString; in the documentation box, so as you suppose, perhaps they just subclassed and implemented it. > If you use any of the character set class methods, Xcode says that they return a NSCharacterSet *, which is what you’d expect. It‘s only when you use them for NSMutableCharacterSet that Xcode says that they return a NSMutableCharacterSet *. And that is correct as well, as a quick look at either the online documentation for class NSMutableCharacterSet or at the header NSCharacterSet.h in any recent version of the OS would have revealed: Apple simply has chosen to redeclare (and likely reimplement) all of the class methods In NSMutableCharacterSet to return a NSMutableCharacterSet. I think I got confused by the class being NSCFCharacterSet Execution of this code: NSMutableCharacterSet *cs; cs = [NSMutableCharacterSet characterSetWithCharactersInString:@"a"]; NSLog(@"class of cs %@ is %@", cs, NSStringFromClass([cs class])); if ([cs isKindOfClass:[NSCharacterSet class]]) NSLog(@"is NSCharacterSet"); if ([cs isKindOfClass:[NSMutableCharacterSet class]]) NSLog(@"is NSMutableCharacterSet"); yields this: 2025-07-22 13:21:52.461091+0200 CSTest[606:9532] class of cs <__NSCFCharacterSet: 0x1020049b0> is __NSCFCharacterSet 2025-07-22 13:21:52.461141+0200 CSTest[606:9532] is NSCharacterSet 2025-07-22 13:21:52.461165+0200 CSTest[606:9532] is NSMutableCharacterSet so... it is a NSMutableCharacterSet and it also means I need to redo the test on 10.4, I got confused by the class name __NSCFCharacterSet Riccardo