Re: string pointer


Steve Mills
 

On Mar 1, 2018, at 06:13:19, Gerriet M. Denkmann <g@...> wrote:

I have a method like (macOS 13.3, Xcode 9.2 (9C40b)):

- (NSUInteger)computeFor: (NSUInteger)arg reason: (NSString * __autoreleasing *)reason
I am not quite sure whether __autoreleasing is the correct annotation. Is it?
Yes.

But my real problem is this:

BOOL needReason = …
NSString *s;
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?
Why not this?

NSString* s;
NSUInteger c = [self computeFor:42 reason:needReason ? &s : nil];

--
Steve Mills
Drummer, Mac geek

Join cocoa@apple-dev.groups.io to automatically receive all group messages.