A
A
Artem2014-07-25 11:57:51
go
Artem, 2014-07-25 11:57:51

(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 {        
    }

But here the comparison condition is set in the code, and cannot be changed by the user. I decided to make it so that the user enters a number in the UITextField, clicks on the Button , which generates a random one, and displays it in the Label.
So, how do I compare the value entered by the user in UITextField and Label ? In ViewController.h I assigned the value : I made the condition like this: Accordingly, this did not give any result. What solution can you come up with? Thank you!
IBOutlet UITextField *chislo;
if (number==chislo) {

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
U
uvelichitel, 2016-04-23
@Kagtaviy

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{   //   = вместо :=

A
agee, 2014-07-25
@iLukas

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 question

Ask a Question

731 491 924 answers to any question