Answer the question
In order to leave comments, you need to log in
(iOS) How to compare number entered in UITextField with value in Label?
Good afternoon!
There is an application that generates a random number. The form has a Button and a Label.
ViewController.m has conditions for generating a number. The value of the generated number is compared with what is specified in the condition, after which the UIAllerView appears.
if (number==5) {
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Совпало!"
message:@"Текст сообщения."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];
}
else {
}
IBOutlet UITextField *chislo;
if (number==chislo) {
Answer the question
In order to leave comments, you need to log in
client needs to be declared globally so that all functions have access to it
and func dbconnect should only assign, not declare
client = redis.NewClient(&redis.Options{ // = вместо :=
You are comparing the pointer chislo to some variable number. You need to access the contents of the UITextField by accessing the text property - this will return you an NSString value. Then you need to get the number from the text variable - call integerValue or floatValue. And only then compare with another value. For example:
NSInteger chisloValue = [chislo.text integerValue];
if (number == chisloValue)
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question