objective c - Quick Multiplication Question - Cocoa -


I'm still learning, and I'm just trapped. I want the user to enter any number and as a result, my program will do this equation:

  x = 5 * y  

( Y that user is the number which is x result)

How do I do this? I'm not sure if I think someone adds to int or NSString . Who should I use, and should I enter anything in the header files?

I'm sure that if I type int or I'm guessing joining NSString .

OK, one of these is a numeric type and the other is a text type how do you multiply text? (In addition to repeating it.)

You need a numerical type.

I take precautions against int , because it can only hold integer, the user will not be able to enter "0.5" and get 2.5; When you change "0.5" to a int , the partial part will be omitted, except the integral part, which is 0. Then you will multiply 5 to 0, and the result will return 0 for the user.

Use double . This is a floating point type; As such, it can hold partial values.

... should I enter anything in the header files?

Yes, but what you enter depends on whether or not you want to use binding (assuming that you actually do not have cocoa or cocoa touch Are talking about).

Annotate an outlet for the text field, without the binding, which you are going to retrieve the multiplier, and in the second text field you are going to insert the product into it to get the multiplier input text Send a double value message to the field, and send the output text field with a setDoubleValue: message.

With binding, declare values ​​to double the values ​​of the double values, with multiplier properties highlighting one-for-one charge for another product , Then synthesize properties and finally, bind the text field 'Binding in those properties' value .


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -