With some high-level languages such as JavaScript or PHP, where the data are not typed or otherwise can not be, we are "spoiled" in compare or convert strings and integers and vice versa, all hidden or manipulated by the interpreter (or compiler ). For example, in JavaScript functions are "forced" (like parseInt() for example) required in special cases. However, in other circumstances we treat without worrying about a particular integer conversions (explicit), such as:
1 2 3 | 5 ; mioNumero var = 5; / / ... "Il valore di mioNumero è " + mioNumero ) ; alert ("The value of mioNumero is" + mioNumero); |
In Objective-C, however, the data type is important and the type conversion must be explicit. Besides the casting (better typecasting) we can use the features and functionality specific to the type conversion. For example, here is how to convert an integer to a string:
1 2 3 4 |
In contrast, here is how to convert a string to an integer:
1 2 3 4 | miaStringa = @ "128" ; NSString * myString = @ "128"; [ miaStringa integerValue ] ; mioNumero int = [myString integerValue]; / / "miaStringa=%@ mioNumero=%i" , miaStringa, mioNumero ) ; NSLog (@ "myString = @ mioNumero% =% i", myString, mioNumero); |






Latest Comments
Simon : It annoys disturbed again and use that space for these things ... however it does not work ...
Giovambattista Fazioli : @ Simon: what could be due to the syntax I used, specifically for PHP 5 +,...
Simon : I tried last night putting everything into functions.php, okay, jquery forms, and tabs jQueryUI them ...
Giovambattista Fazioli : @ Simon: I recommend cleaning to enter a code like that in ...
Simon : @ Giovambattista Fazioli: Thank you for your patience, it's all clear ... now I feel now, ...