最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]swift代码出错: ARC forbids explicit message send of ‘autorelease’

iOS crifan 2831浏览 0评论

代码:

        // Add the password to the dictionary, converting from NSData to NSString.

        NSString *password = [[[NSString alloc] initWithBytes:[passwordData bytes] length:[passwordData length]

                                                     encoding:NSUTF8StringEncoding] autorelease];

        [returnDictionary setObject:password forKey:(id)kSecValueData];

出错:

 ARC forbids explicit message send of ‘autorelease’

如图:

搜:

encoding NSUTF8StringEncoding ARC forbids explicit message send of ‘autorelease’

iOS编程过程中出错:’autorelease’ is unavailable

ios开发之路十一(ARC forbids explicit message send of ‘autorelease’错误) – Lves Li – 博客园

还是使用ARC,

去改为:

//        NSString *password = [[[NSString alloc] initWithBytes:[passwordData bytes] length:[passwordData length]

//                                                     encoding:NSUTF8StringEncoding] autorelease];

        NSString *password = [[[NSString alloc] initWithBytes:[passwordData bytes] length:[passwordData length]

                                                     encoding:NSUTF8StringEncoding] init];

即可。

转载请注明:在路上 » [已解决]swift代码出错: ARC forbids explicit message send of ‘autorelease’

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
85 queries in 0.192 seconds, using 22.05MB memory