Limit a NSMutablestring's length [closed] - ios

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.

Related

How to access MACD value and signal (both 2 data) in mql4 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am trying to create a robot in mql4 for forex trading.So i need to access both MACD value and MACD signal value.But it looks like only providing MACD value without MACD signal value.Please help me to access those values.
enter image description here
It provides u with both value pls look to my code
double macdBaseIndicatorLine = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
double macdSignalIndicatorLine =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
thats how you get the values, pls give me a like if it helps u thx

Telephone mask (number format) with variable lenght [closed]

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 2 years ago.
Improve this question
I was looking for the best solution to mask cells with telephone numbers like the example:
(+55 11) 99999-9999
Normally I'd use (+## ##) #####-#### as a custom number format. The problem is that the length of the number may vary. Nine numbers for cellphones and eight for home numbers. So, with a mask like that, an eight number phone would be formated like (+5 51) 19999-9999
Well, while posting this question I found the solution I wanted using Custom Number Format with conditions based on the number value.
[<=999999999999](+00 00) 0000-0000; [>999999999999](+00 00) 00000-0000;

NSDecimalNumber to double. What is the correct way to do this in Swift [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I've been searching for a clean and correct way to convert an NSDecimalNumber retrieved from CoreData to a Double.
I'm looking for a recommendation on how to do this. I need to take 2 decimal numbers from my CoreData and calculate a percentage to use in a progress bar etc.
NSDecimalNumber has a property var doubleValue: Double { get }. So you can say num.doubleValue.
For division of two NSDecimalNumbers you should use num1.dividing(by: num2).
Keep in mind that in Swift you can also use Decimal which supports +, *, /, etc.

Make lowercase letters in a string uppercase [closed]

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.

A calculator app on iOS [closed]

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
Can anyone please explain the difference between this
[display setText:[[display text] stringByAppendingString:digit ]];
and this
[display setText:digit];
The code is rather clear. But if you don't understand:
Here [display setText:[[display text] stringByAppendingString:digit ]]; a new digit will be added to the digits currently displaying on the screen. This BOOL value userIsInTheMiddleOfTypingANumber is extremely straightforward - it is said that there are always digits on the screen and a new digit must be added to them. This method stringByAppendingString returns a new string made by appending a given digit to the currently displayed digits in the UITextField.
And here [display setText:digit]; all the text which are displayed in the UITextField will be overwritten with a new digit value. But as I suppose it is used when there are no digits on the screen and we need to write the first one.I don't know what is using for displaying digits in that app. But if it is UITextField then using setText is a bad idea - it is a deprecated method. You should use text property instead.
This is an extremely simple code which you need to understand yourself. So my advice you to read some introductory books on CocoaTouch and iOS with simple examples there are plenty of them: http://www.amazon.com/Beginning-iOS-Development-Exploring-SDK/dp/1430245123/ref=pd_sim_b_8 . And don't forget to use official documentation.

Resources