Gerriet M. Denkmann
I have a method like (macOS 13.3, Xcode 9.2 (9C40b)):
- (NSUInteger)computeFor: (NSUInteger)arg reason: (NSString * __autoreleasing *)reason
// some computing…
if ( reason != NULL ) *reason = @“Used Chebycheff approximation”;
to be use like:
NSUInteger a = [ self computeFor: 12 reason: NULL ]; // don’t care for reason
NSUInteger b = [ self computeFor: 99 reason: &s ]; // want to know reason
I am not quite sure whether __autoreleasing is the correct annotation. Is it?
But my real problem is this:
BOOL needReason = …
NSString **stringPointer = needReason ? &s : NULL;
NSUInteger c = [ self computeFor: 42 reason: stringPointer ]; // sometimes want to know the reason
I cannot figure out how to declare the stringPointer without getting compiler warnings.
How to do this?