все еще новичок в iPhone SDK, но мне это до сих пор нравится ...
я просто иду по курсу, обучающему онлайн и немного запутался, я пытаюсь в основном иметь UITextField и кнопку submit(AKA: кнопка GO на клавиатуре)
h file ..
IBOutlet UITextField *InsertUITextFieldBox; // UITextField to input keystrokes..
IBOutlet UILabel *myLabel; // UILabel to show if answer is correct or incorrect..
}
-(IBAction)dropMyKeyboard; // Setup to Say go - and IB - DidEndonExit on my UITextField
my .m file
-(IBAction)dropMyKeyboard{
NSString *TypedinbyUser = [[NSString alloc] initWithFormat:@"%@", [InsertUITextFieldBox text]]; //saves data in uitextfield to a nsstring
NSString *CorrectAnswer = [[NSString alloc] initWithString:@"http://google.com"]; //answer to used to compare in if statement with uitextfield
[myLabel setText:TypedinbyUser]; // show what was typed in my user
//if statement, if what user types is correct to the CorrectAnswer, then display the following if right or wrong....
if (TypedinbyUser == CorrectAnswer) {
[myLabel setText:@"You Answered Correctly"];
}
[myLabel setText:@"You Answered Incorrectly"];
}
так что да, когда я запускаю это,и набрал "http://google.com" в моем текстовом поле и нажмите GO - моя UILabel переходит к" Вы ответили неправильно ", когда я точно знаю, что я набрал, как я скопировал и вставил его из своего кода, без кавычек, а также набрал вручнуюи попытался добавить пробелы до и после ....
любая помощь была бы полезна в том, что я делаю неправильно .. спасибо