gpt4 book ai didi

objective-c - ARC 强属性枚举错误

转载 作者:太空狗 更新时间:2023-10-30 03:11:25 25 4
gpt4 key购买 nike

我有以下代码,但在编译前遇到此错误:

Fast Enumeration Variables can't be modified in ARC by default, declare the variable _strong to allow this

for (NSString *name in array){
@try {
S3ObjectController *localS3 = [[S3ObjectController alloc]init];
name = localS3.stringProperty;
}

在这个 S3ObjectController 类中,我声明了如下属性:

@property (nonatomic, strong)  NSString *stringProperty;

我应该如何更改属性?我以为我在宣布它很强大?

最佳答案

这意味着声明快速枚举变量 strong,而不是你的实例变量:

for (NSString __strong *name in array) {
@try {
S3ObjectController *localS3 = [[S3ObjectController alloc]init];
name = localS3.stringProperty;
}
}

关于objective-c - ARC 强属性枚举错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8973795/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com