【发布时间】:2017-05-08 07:49:25
【问题描述】:
每当我尝试从文本字段中获取输入时,都会收到此错误。有人可以帮忙吗?
2017-05-08 17:45:04.962124 MyPhotos[32987:246251] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/local/Library/Developer/CoreSimulator/Devices/05F02AB6-BDEA-43EA-9E7E-D547D3A0CC1A/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-05-08 17:45:04.962486 MyPhotos[32987:246251] [MC] Reading from private effective user settings.
代码:
class AddPhotoController: UIViewController,UITextFieldDelegate {
@IBOutlet weak var photoTitle: UITextField!
@IBOutlet weak var photoTags: UITextField!
@IBOutlet weak var photoURL: UITextField!
@IBOutlet weak var photoPreview: UIImageView!
@IBAction func savePhoto(sender: AnyObject) {
let title: String = photoTitle.text!
}
}
【问题讨论】:
-
当我运行代码并尝试获取它总是返回 nil 的值,然后应用程序崩溃了。
-
我不认为以上是您错误的实际原因。我也时不时看到“从私人有效用户设置中读取”(并且没有崩溃:))看看这里例如:stackoverflow.com/a/40458288/4063602,或这里:stackoverflow.com/q/41416048/4063602 似乎是 Xcode 中的一个错误。那么...您能否向我们展示您的一些代码,以便我们帮助您确定导致崩溃的原因?
-
是的,我有。但是假设我有一个按钮,我想在按下它时获取文本字段的值@IBAction func savePhoto(sender: AnyObject) { let title: String = photoTitle.text!这总是返回 nil 并且应用程序在这一点上卡住了。我确实尝试过检查断点,但我总是返回 nil
-
请看代码。