Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
This is the best reduced case of I am seeing
NSString * test = #"??( ";
NSLog(#"'%#'", test);
console> '['
I have a work around
NSString * test = #"\x3f\x3f(";
NSLog(#"'%#",test);
console> '??('
It seems like this is likely caused by string interpolation or similar process in the NSString object vivification. I'm posting this question for two reasons.
1) anyone happen to know what is actually causing this?
2) I didn't find anything on this 'feature' of NSString and it took me an hour to track down the bug, so this is just a bread crumb for future programmers. Using the hex code for the character was the work around.
NSlog("'%#'", test); is syntactically incorrect. How are you compiling it with this syntax error?
If I change it to NSLog(#"'%#'", test);, it works correctly (note the string literal denoting # and the uppercase L in NSLog).
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am decoding data as shown on the right window and then using it to output a model via the initializer defined in the middle one. However, when I try to use it, I am being told that I am passing the wrong argument type.
Why is it that I am getting an error that the initializer is expecting a String, if I have defined it in the Model (the middle screen) to explicitly expect a [String] ?
Screenshot
The two of the arguments - genre and backgroundImage - are swapped, which causes the issue with the Initializer.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have a string which is something like:
ABC:Something|Hello World
I want the data after '|' character so I am using regex for it.
sample_str = "ABC:Something|Hello World"
puts sample_str.match(/[^|]*$/)
This works on rubular and returns me "Hello World" as the output, but doesn't work in my ruby code. What am I missing here? I get #<MatchData ""> in Ruby.
UPDATE: Nevermind. If I use the regex and do match on the string it works now. I was doing it other way round i.e. I did (regex).match(string) instead of (string).match(regex).
Thanks for looking!
Using regex seems excessive:
string.split('|').last
Below regex should help you.
^[\S\s]+?\|([\w\s]+)$
Dont forget to select global and multiline options.
Look at the regex demo here.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I want that every time a user clicks a button the number inside of it increases by 1. Below is the code to do that which works fine. However i want it to be in brackets e.g (1) when they press the button changes to (2) etc. How do i do this?
Thanks
-(IBAction)passButton:(id)sender{
passCounter = passCounter + 1;
passLabel.text = [NSString stringWithFormat:#"%i",passCounter];
}
-(IBAction)passButton:(id)sender{
passCounter++;
passLabel.text = [NSString stringWithFormat:#"(%i)",passCounter];
}
passLabel.text = [NSString stringWithFormat:#"(%i)",passCounter];
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
In ruby i have a string like this:
str= 43,69 €
Is possible with a regex obtain 43,69 ?
I have tried with:
/\d+(?:\.\d+)?/
but the output is incorrect: 43.0
This should work
/\d+(?:[.,]\d+)?/
The [.,] part matches decimal separator for a dot or a comma. If you are sure thet decimal separator will be a comma, you can use this:
/\d+(?:,\d+)?/
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Are there any methods for taking a string and converting all lowercase letters to uppercase?
I was thinking of making a for-loop to run through, check each character, see if it is in range 0061-007A (lowercase letters) and just subtracting 26 (base 16) (converts to the uppercase counterpart) from the unicode code and adding that character back to the string.
But I figured I'd check if there is a simpler method already out there... googled but couldn't find anything... I'm sure I could use a 1x1 UIWebView and load some javascript (that does this) with my string into the UIWebView but there has got to be something already in Objective-C other than the manual approach I first mentioned right?
You do not need a loop - you can use either
NSString *upper = [src uppercaseString];
or
NSString *upper = [src uppercaseStringWithLocale:myLocale];
for targeting a specific locale.