On 14 Nov 2017, at 21:19, Wolfgang Lux <[email protected]> wrote: > > So next time you probably should define your validateMenuItem: like this > (beware, untested code): > > - (BOOL) validateMenuItem: (SEL)aSelector > { > aSelector = NSSelectorFromString([NSStringFromSelector(aSelector) > stringByAppendingString: @"IsEnabled"]); > if ([self respondsToSelector: aSelector]) > return (BOOL)[self performSelector: aSelector]; > return YES; > }
That’s not quite right, because you need to strip the trailing : from `NSStringFromSelector(aSelector)`. It’s a bit annoying to do it here, because the NSMenuItem could cache the selector once per program invocation, rather than having to reconstruct it with string manipulation on each call. Probably not a performance difference that’s noticeable to a human, but it seems inelegant. Unfortunately, that’s what we’re stuck with if we want OpenStep / Cocoa compat. David _______________________________________________ Discuss-gnustep mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnustep
