On 03/05/2019 14:05, Fred Kiefer wrote:
Thanks ! I feared it was too simple. So I still get the same problem : the
error in gcc does seem to come from the fact that [self themeControlState]
returns an id (because private) when GSThemeControlState is an enum and not a
pointer.
When I tried declare a category of NSButtonCell to have this function public,
I thought I could use a selector to perform the call . But I still get the same
problem now : how will I have a return value that is for sure a
GSThemeControlState ?
Why would you use the selector if you already declared a category. Just having
a category and using the method normally in the file should work.
I believe the confusion is that we are suggesting that you *declare* a
category, not *implement* a category.
If you have a class A with a header like this:
@interface A : B
- (void)foo;
@end
And a .m file that contains this:
@implementation A
- (void)foo {}
- (int)bar { return 42; }
@end
You can add a category *declaration* in another file like this:
@interface A (SecretStuff)
- (int)bar;
@end
This tells the compiler that you expect A to implement a method called
bar that takes no arguments and returns int. If you then call it and it
does not exist, you will get an exception. If you call it and the
return types / argument types don't match then the GNUstep runtime will
either raise an exception or warn you (depending on how you've
configured it), other runtimes will do unexpected things up to and
including corrupting your stack.
You don't need to provide an @implementation for this category, the
compiler assumes that one exists in another compilation unit.
David
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep