-1
프로그래밍 할 때 완전한 초보자입니다. 따라서 제 질문에 초보자도 올 수 있습니다.iOS swift : 필드에 IF 문이없는 값일 때의 경고
버튼을 클릭 할 때 사용자 위치로 채워지는 UILabel이 있습니다. 그러면 사용자는 모든 세부 정보를 구문 분석 할 수 있습니다.
if userLocation.text == nil {
let alert2 = UIAlertController(title: "Oops!", message: "Please provide your location", preferredStyle: UIAlertControllerStyle.Alert)
alert2.addAction(UIAlertAction(title: "Close", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert2, animated: true, completion: nil)
} else {
//var location = PFUser.currentUser()
//location["location"] = userLocation.text
//location.save()
}
나는 어떻게 말 할 지 모르겠다. UIField에 값이 없다면 경고를 실행한다.
즉이 부분. UILabel의 : 죄송합니다
if userLocation.text == nil {
는 userLocation가 @IBOutlet의 var에 userLocation을 언급하는 것을 잊었다! – Rogog
당신이 이미 말하고있는 것에는 무엇이 문제가 있습니까? 'if userLocation.text == nil'은 테스트입니다. 물론 그것은 non-nil 일 수도 있지만 빈 문자열 인''''일지도 모르니, 아마 당신도 그것을 테스트하고 싶을 것입니다. – matt
감사합니다 매트 - ""매력을 일했습니다! – Rogog