我正在測試用戶名真實性的服務器響應。如果服務器響應「用戶缺席」,則意味着彈出一個UIAlertView。UIAlertView不顯示
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *responseString1 = [[NSString alloc] initWithData:responseData1 encoding:NSUTF8StringEncoding];
NSLog(@"%@",responseString1);
NSString *response = responseString1;
NSLog(@"%@",response);
if ([response isEqualToString:@"User absent"]) {
_userAbsent = [[UIAlertView alloc]initWithTitle:@"Error" message:@"1. Display Name missing.\n2. Password missing." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
self.userAbsent.delegate = self;
[_userAbsent show];
}
我輸入了僞造的錯誤一些隨機的用戶名和密碼,但警報視圖只是沒有彈出。 NSLog是否從服務器獲得兩次數據。
這是日誌輸出:
2013-03-28 20:59:35.542 SimpleTable[1429:f803] "User absent"
2013-03-28 20:59:35.542 SimpleTable[1429:f803] "User absent"
我還有一個UIAlertView中之前,從服務器,它提醒如果兩個用戶名和密碼字段缺少請求數據。該AlertView工作但是。
- 在這個問題上的任何指針?
- 我知道AlertView可以是一個痛眼。無論如何提醒用戶不使用AlertView?
比預先...
您收到的字符串是否被引用?它從'NSLog'行看起來是該字符串被雙引號包圍,這不是你正在測試的內容。 – bdesham
_userAbsent在哪裏定義? – Josiah
另外,你是否記錄你的if語句,看看它是否甚至經過那裏? – Josiah