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
4
votes
2 answers
Why whitespaceAndNewlineCharacterSet doesn't remove spaces?
This code SHOULD clean phone number, but it doesn't:
NSLog(@"%@", self.textView.text);
// Output +358 40 111 1111
NSString *s = [self.textView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSLog(@"%@",…

JOM
- 8,139
- 6
- 78
- 111
4
votes
2 answers
Remove last punctuation of a swift string
I'm trying to remove the last punctuation of a string in swift 2.0
var str: String = "This is a string, but i need to remove this comma, \n"
var trimmedstr: String =…

Vitalik K
- 47
- 1
- 6
4
votes
0 answers
creating NSCharacterSet with Unicode SMP entries & testing membership -- is this a bug?
Given the code:
NSString *a = @"a";
NSString *clef = @"";
UTF32Char utf32char = 0x1D11E; //
NSCharacterSet *cs1 = [NSCharacterSet characterSetWithCharactersInString:@""];
NSCharacterSet *cs2 = [NSCharacterSet…

Orangenhain
- 3,724
- 1
- 22
- 16
3
votes
1 answer
What is differnce between NSString and NSCharacterset?
I studying NSCharacterset class.
NSString and NSCharacterset look like similar class.
Who can explain difference between NSString and NSCharacterset?
When use NSCharacterset?
Thanks your help..

S.J. Lim
- 3,095
- 3
- 37
- 55
3
votes
2 answers
Value of type CharacterSet has no member InvertedSet - Swift 3
I am trying to convert over swift 2 code to swift 3:
var customAllowedSet = NSCharacterSet(charactersInString:"=\"#%/<>?@\\^`{|}").invertedSet
It throws this error:
Value of type CharacterSet has no member InvertedSet

Tim Nuwin
- 2,775
- 2
- 29
- 63
3
votes
1 answer
allow english and arabic numbers input UITextField swift
I write code that only allow english number in UITextField and I want to check arabic numbers and allow thats.
this is my code :
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String)…

MmD
- 2,044
- 5
- 22
- 41
3
votes
1 answer
UITextfield content validation (letters, numbers and special punctuation marks)
I have a UITextfield that holds an username field, then I would like to add a validation so user cannot type a username that is different from letters, numbers and "_-." punctuation marks. I'm trying to use NSCharacterset to do that but without…

vilelam
- 804
- 1
- 11
- 19
3
votes
1 answer
UITextField - Prevent user from typing non-standard characters (like Emoticons)
My app creates and stores EKEvents into the standard Calendar database, however, I've found that if I use an emoticon as the "notes" for an event, it causes a crash when trying to read the event out of the Calendar.
I don't want or need the use of…

jhilgert00
- 5,479
- 2
- 38
- 54
2
votes
1 answer
How to set a dialog code page in rc-file
I use VS 2010 and write in C++. How can i set a dialog codepage in a resource file (rc-file)?
I output a text through DrawText Win API function. I draw text right in a dialog (not in its child contols). I need to draw the "single right-pointing…

Vitaly
- 597
- 1
- 5
- 12
2
votes
1 answer
How to Print the characterset of a Font?
I have downloaded a font from the internet. Now I want to Print the Characterset of that font. I got the CFCharacterSetRef of that font. But I don't know how to print that CFCharacterSetRef. This is my coding.
NSString…

Aravindhan
- 15,608
- 10
- 56
- 71
2
votes
1 answer
Strange Behavior In CharacterSet.contains() Method, With High UTF8 Characters Mixed With ASCII
Here's the deal: I am creating a StringProtocol extension to add the ability to do a split, based on a character set (any character in the set is used to split -greedy comparison).
The issue is that I am having difficulties comparing against a…

Chris Marshall
- 4,910
- 8
- 47
- 72
2
votes
1 answer
How to know which CharacterSet contains a given character?
Is there a way to check if a character belongs to a CharacterSet?
I wanna know what CharacterSet should I use for character -. Do I use symbols?
I've checked this documentation but still no idea.…

Glenn Posadas
- 12,555
- 6
- 54
- 95
2
votes
2 answers
Trimming characters of NSXMLParser
What is the right way to trim characters in foundCharacters of NSXMLParser?
I've found many examples that do it like this:
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
NSString *characters = [string…

hpique
- 119,096
- 131
- 338
- 476
2
votes
2 answers
How come I didn't have to instantiate the NSCharacterSet object first before using it?
I'm following a tutorial learning about delegates and protocols while using the UITextField object. In the tutorial I noticed that I didn't have to instantiate the NSCharacterSet object first by typing
let letterCharacters = NSCharacterSet()
The…

Laurence Wingo
- 3,912
- 7
- 33
- 61
2
votes
2 answers
Force NSTextField to Only Accept Decimal (#.#) Numbers and Periods
I'm trying to make it so an NSTextField will only accept numbers and periods like 12.4 and 3.6 in a Mac app.
I feel like I'm getting pretty close after reviewing other SO questions, but I can't quite get it. The below code works except that it won't…

Clifton Labrum
- 13,053
- 9
- 65
- 128