什麼是驗證和檢查用戶輸入到UITextField中的字符串的最佳方式?iPhone:在UITextView中驗證文本輸入 - 最佳方式?
我的工作流程如下: 1)用戶啓動視圖 2)視圖包含多個UITexFields 3)用戶填寫UIText字段 4)用戶點擊「保存全部」按鈕 5)內的該串內數據UITextFields進行身份驗證,看看他們是否可以接受 6)活動指標正在進行身份驗證 7)成功後視圖彈出和信息發佈 8)如果不成功,UIActionsheet彈出並通知用戶哪些字段是不正確的以及可接受的參數是什麼。
我的問題是這樣的:我使用正則表達式來驗證字符串?如果有的話,是否有任何有用的教程或鏈接用於此目的?
下面是代碼:
-(IBAction)saveAllButtonPressed
{
//Authenticate input ie: strings here
//TO BE IMPLEMENTED
if(!passedAuthentication)
{
//show UIActionsheet here
}
else //If passed authentication save everything and pop off the view
{
//sanitize input before storing in customer info model ie. take out dashes, strings etc..
//TO BE IMPLEMENTED
Cart.customerInfoObtained = YES;
infoModel = [[customerInfoModel alloc] initWithObjects:self.Name.text
AptNo:self.AptNum.text
Street1:self.Street1.text
Street2:self.Street2.text
City:self.City.text
Tel:self.Telephone.text
Email:self.Email1.text];
[Cart addCustomerInfo:infoModel];
}
}