最新消息:20210917 已从crifan.com换到crifan.org

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

iOS crifan 2254浏览 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,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
95 queries in 0.271 seconds, using 23.32MB memory