You must first understand that there is no built-in data type in either C, C++ or Objective-C. Unlike C however C++ and Objective-C standard libraries provide standard string classes that essentially add a string type. In C a string is merely a convention using a character array with a nul terminator, which is supported by a library for performing operations such as assignment and comparison.
I am no Objective-C expert and find the language syntax arcane and the documentation unfathomable, however I believe that this
may be what you are after.
The pedant in me feels the need to clarify some terms used in your question:
does not represent a decimal, it represents an approximation of a real
number (as opposed to an integer
) using a binary representation. That representation is typically a binary-floating-point representation and as such there are many decimal values that it cannot precisely represent. There are decimal-floating-point representations that can accurately represent decimal values, but there is no built-in type in Objective-C for that, and most underlying FPU hardware does not directly support it, so it is intrinsically slower. C# is one language that does have a decimal
A "literal" is a direct value rather than a variable, so "declaring a literal
" is an oxymoron. For example "ABC123" is a string literal, 12345 is an integer literal.
I believe that what you intended to ask is how you can declare a variable of string type, or possibly how to declare a variable and assign or initialise it with a string literal?