This question already has answers here:
How to add percent sign to NSString
(7 answers)
Closed 9 years ago.
How to print symbol "%" in NSLog ???
NSLog(#"str %");
It gives warning
incomplete format specifier
How to resolve this problem?
try this
NSLog(#"str : %%");
Thanks
Just use two percent signs:
NSLog(#"str %%"); //prints "str %"
Here is the list of format specifiers for all types of data printing which can be useful for iOS programming.
You need to print like this
NSLog(#"%%");
use this code
NSLog(#"str %%");
Related
This question already has answers here:
How do I convert this Ruby String into an Array?
(6 answers)
Closed 6 years ago.
My string is
"[1,2,3]"
I want to get output in the below format
[1,2,3]
I want to extract array present in my string.
Just parse it with JSON.parse method like this ;
JSON.parse("[1,2,3]")
You can use eval:
try:
eval("[1,2,3]")
=> [1, 2, 3]
Ok, try it:
"[1,2,3]".scan(/\w/).map{|x| x.to_i}
This question already has answers here:
what is "?" in ruby
(3 answers)
Closed 7 years ago.
I am trying to understand what this means
variableName * ?*
I understand that VariableName is being multiplied with something, but what does ?* mean? Is this regex and does it mean that I'm appending '?' and anything that comes after it?
?c is not a regex, is the short syntax for '*'. That is, ?a is 'a', ?b is 'b' etc...
What is going on in your program is probably something like:
["ab","cd","ef"] * ?*
#=> "ab*cd*ef"
This question already has an answer here:
escape % in objective c
(1 answer)
Closed 8 years ago.
I want to write sql query in NSString, the query is:
WHERE fa_name LIKE '%anyValue%'
I wrote the following code
NSString *whereFamilyName = [NSString stringWithFormat:#"fa_name LIKE '\%%#\%'", typedFamilyName];
but it doesn't escape the % and the output is:
fa_name LIKE '%#'
To Escape a % simply write two %%.
NSString *string = [NSString stringWithFormat:#"fa_name LIKE '%%%#%%'", #"val"];
This question already has answers here:
Objective c doesn't like my unichars?
(3 answers)
Closed 9 years ago.
I'm trying to add some specific characters to my
unichar rusLetter [] = { 'Ж', 'Й', }
I want actually to add all letters from russian alphabet. Using above line of code, i get an error:
Character too large for enclosing character literal type
Any ideas how to fix that? And maybe there is an easier way to add all letters, not to type all of them.
Thanks
the ' literal (single quote) means a char and that is too small to hold the symbols.
In ObjC use an NSString to hold it
NSString *rusLetters = #"ЖЙ";
unichar c1 = [rusLetters characterAtIndex:0];
unichar c2 = [rusLetters characterAtIndex:1];
This question already has answers here:
How to escape double quotes in string?
(3 answers)
Closed 10 years ago.
I have a string that has multiple " in it, which is written inside of #"" and of course, xcode sees this as me ending the #". Is there any alternatives I can use for #"" that would do the same thing?
It's done with escape chars. #"My name is \"Someone\". Blabla.";