最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

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

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

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
62 queries in 0.240 seconds, using 18.81MB memory