I'm using Objective-C, and I don't know how to create and call a method with out parameters when compiling the code with the ARC compiler.
This is the kind of thing I'm trying to accomplish in non-ARC Objective-C (this is probably wrong anyway).
//
// Dummy.m
// OutParamTest
#import "Dummy.h"
@implementation Dummy
- (void) foo {
NSString* a = nil;
[self barOutString:&a];
NSLog(@"%@", a);
}
- (void) barOutString:(NSString **)myString {
NSString* foo = [[NSString alloc] initWithString:@"hello"];
*myString = foo;
}
@end
I've read the documentation here: https://clang.llvm.org/docs/AutomaticReferenceCounting.html
...but am finding it difficult to get anything that compiles, never mind anything that is correct. Would anybody be able to rewrite the jist of the code above, in a way that is suitable for ARC Objective-C?
&a
directly. – Bibeaub
variable, just pass in&a
as the argument. You also don't need to use__autoreleasing
on thea
andb
variables unless you need to access the initial value inbarOutString:
which isn't very common. – Bibeau