Swift使IBOutlet变得强大 [英] Swift making IBOutlet as strong

查看:54
本文介绍了Swift使IBOutlet变得强大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Swift中,默认情况下,IBOutlets是弱的.我在情节提要中创建的 viewController 中有一个不在视图层次结构中的对象,因此我需要它成为 ViewController 中的重要参考,如何更改<将strong> @IBoutlet 属性设为强.

IBOutlets are weak by default in Swift. I have an object in the viewController Created in the storyboard which is not in the view hierarchy , So I need it to be a strong reference in ViewController , How can I Change @IBoutlet property to strong.

推荐答案

从Xcode 6 beta 2开始,Swift无法指定强大的渠道.解决方法是在IB中连接插座,然后从源文件中删除 @IBOutlet 属性.

As of Xcode 6 beta 2, Swift does not have a way to designate strong outlets. The workaround is to connect the outlet in IB, then remove the @IBOutlet attribute from your source file.

更新:这已在Xcode 6 beta 3中添加.

Update: This has been added in Xcode 6 beta 3.

这篇关于Swift使IBOutlet变得强大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆