我正在使用Objective-C,并且在使用ARC编译器编译代码时,我不知道如何创建和调用没有参数的方法。
这是我试图在非 ARC Objective-C 中完成的事情(无论如何这可能是错误的)。
//
// 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
我在这里阅读了文档: https ://clang.llvm.org/docs/AutomaticReferenceCounting.html
...但是我发现很难得到任何可以编译的东西,更不用说任何正确的东西了。任何人都能够以适合 ARC Objective-C 的方式重写上述代码的 jist 吗?