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];
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 7 years ago.
Improve this question
I need to subtract 15 minutes from a date. Note understanding why following is not working:
eventDate = event.date;
NSDate *alarmDate = [[eventDate] dateByAddingTimeInterval:-60*15];//this is throwing error "Expected identifier"
Thanks for any suggestions.
You've got a syntax error in your code, square braces must only be used when you are sending a "message" to an object. Do not use Objective-C square brace syntax in any other situation.
Here is the correct code:
eventDate = event.date;
NSDate *alarmDate = [eventDate dateByAddingTimeInterval:-60*15];
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).
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
ForExample:
String is---book
I want "book". Because Second time it will change to another thing.So i am not using NSRange.
Any Solution?
Thanks
NSArray *array = [myString componentsSeparatedByString:#"---"];
NSString *bookString = array[1];
Your question is not very clear, but you may need to use this:
NSString* myString = [myPrevString stringByReplacingOccurrencesOfString:#"---" withString:#""];
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am working on a calculator App.
The NSMutablestring is used for calculation E.g "5-3*8-(-1)/77".
But the label can't display endless an NSMutablestring, so is there have any way to limit NSMutablestring's length?
(not too long, I want the NSMutablestring's length to be less than 100).
You can get the first 100 characters of a string as follows:
NSString *first100chars = [myString substringToIndex:100];
However, it sounds like you need to prevent the user from actually entering a string this long, which is a different problem. The comments to your question give examples of other people asking similar questions (e.g. Set the maximum character length of a UITextField), I suggest you check those.
This is a job for an NSFormatter subclass. That's exactly what it's for.