An NSCharacterSet object represents a set of Unicode-compliant characters. NSString and NSScanner objects use NSCharacterSet objects to group characters together for searching operations, so that they can find any of a particular set of characters during a search. The cluster’s two public classes, NSCharacterSet and NSMutableCharacterSet, declare the programmatic interface for static and dynamic character sets, respectively.
Questions tagged [nscharacterset]
102 questions
1
vote
1 answer
Check if NSString is valid number - whole or decimal number
I have an iOS app with a UITextField that allows the user to enter a number in. How can I ensure that the value the user types in is a valid number (either whole or decimal). Here is what I have tried, but for some reason it won't work for decimal…

Supertecnoboff
- 6,406
- 11
- 57
- 98
1
vote
1 answer
Trying to define a custom NSCharacterSet with unicode characters in Swift
I want to define in Swift an NSCharacterSet containing: [A-Z] (note the double-bytes, this is not [A-Z]).
What is the proper syntax to do that? The code below that I had working in Objectiv C doesn't seem to translate to Swift so easily.'
…

Michel
- 10,303
- 17
- 82
- 179
1
vote
2 answers
rangeOfCharacterFromSet: with numeric set
Hoi!
I got a NSString which looks something like this: "$1.00". Always a currency symbol with a value.
I format this string to remove the symbol and any non-decimal characters with str = [str stringByTrimmingCharactersInSet:[[NSCharacterSet…

Peter Meinhardt
- 23
- 5
1
vote
1 answer
How to fix crash bug on componentsSeparatedByCharactersInSet?
I am making IOS app related AddressBook.
When I called below function for get phone number which have "+" symbol, I got crash error sometimes.
Anyone know this error?
Basically I am getting error on componentsSeparatedByCharactersInSet function.
-…

James Chan
- 97
- 2
- 12
1
vote
1 answer
how to do UItextfield should allow only value between Range
My Problem is i have to do Like User can enter values in Range ... My range is coming from json
here's my code whatever i tried ... here a,b is my start range and b is end range user can enter values better this range not out of range
-…

Mayank Patel
- 3,868
- 10
- 36
- 59
1
vote
1 answer
NSString:componentsSeparatedByCharactersInSet inclusive
NSString *infix = @"4+23-54/543*23";
NSCharacterSet *operatorSet = [NSCharacterSet characterSetWithCharactersInString:@"+-*/"];
NSArray *tokens = [infix componentsSeparatedByCharactersInSet:operatorSet];
tokens returns:
[@"4", @"23", @"54",…

Daniel Node.js
- 6,734
- 9
- 35
- 57
1
vote
1 answer
NSCaseInsensitiveSearch not works in rangeOfCharacterFromSet
It seems that NSCaseInsensitiveSearch not works in NSString:rangeOfCharacterFromSet. Can someone explain why? is it correct behaviour?
NSString *string = @"James Bond Always Rocks";
NSRange range = [string rangeOfCharacterFromSet:[NSCharacterSet…

Avt
- 16,927
- 4
- 52
- 72
1
vote
4 answers
Parsing text, but keeping punctuation
I'm using this little piece of code to go through some inputted text and extracting sentences separated by the markers:
NSCharacterSet *punctuation =
[NSCharacterSet characterSetWithCharactersInString:@".!?\n"];
NSArray *parts = [data…

Malfunction
- 1,324
- 4
- 15
- 25
1
vote
2 answers
Check if UITextfield contains (? ! $ , etc)
Im doing a conditional statement that checks if a textfield contains certain characters, if it does they an UIAlertView will show. At the moment if the text field contains letters then an the alert is shown, how would I extend my method below to…

DevC
- 6,982
- 9
- 45
- 80
1
vote
2 answers
Detect the presence of nonbreaking space in NSString?
I'm trying to create an NSCharacterSet that I can use to test whether a character is a whitespace or not. This character set:
[NSCharacterSet whitespaceAndNewlineCharacterSet]
does not include non-breaking spaces, so I'm attempting to build my own…

user714171
- 363
- 1
- 3
- 12
0
votes
2 answers
Is there any possibility to use more than one NSCharacterSet Object for the same NSString?
Consider this code:
NSString *aString = @"\tThis is a sample string";
NSString *trimmedString = [aString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSLog(@"The trimmed string: %@",trimmedString);
trimmedString =…

Ram Gandhi
- 707
- 8
- 24
0
votes
1 answer
How to find number of special characters in sting in objective C
Help me find the same, tried searching many questions all I found was to check if the string contains a special character, but I want to find the number of special characters in a string in objective - c
0
votes
2 answers
NLS_CHARACTERSET in nls_session_parameters returns None
An application I'm using with Oracle seems to be having issues with characters, and I ran the queries below to check on the CHARACTERSET.
SELECT * FROM nls_session_parameters WHERE PARAMETER='NLS_CHARACTERSET';
SELECT * FROM nls_database_parameters…

Sattesh Maran
- 11
- 1
- 3
0
votes
1 answer
append :00 to whatever is entered in the textfield
My code below restricts the user to only input 2 numbers into a textfield. All I want to do is append ':00' to whatever is entered into whatever is entered into the textfield. So if the user enters 30. The textfield should be 30:00. All code is…
user12418101
0
votes
0 answers
How to split a NSString keeping specific punctuations?
I need to split a sentence in specific punctuation marks, but keeping these punctuations.
I'm doing it like this:
NSCharacterSet *delimeter = [NSCharacterSet characterSetWithCharactersInString:@"***"];
sentence = [sentence …

neowinston
- 7,584
- 10
- 52
- 83