Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSCharacterSet - append another character set

I would like to create a character set that includes all of its own characters, as well as those from another character set. Append in other words.

I thought there'd be an obvious way, but after control-space completion in the IDE, and then poking around the docs, I couldn't fine anything.

I can see how to append all the characters from a string. But I need to append the characters from another set. I guess I could to-string the second set, if there's a to-string method.

How do I do this?

like image 518
Jasper Blues Avatar asked Sep 15 '13 05:09

Jasper Blues


2 Answers

You are probably seaching for this method in NSMutableCharacterSet :

- (void)formUnionWithCharacterSet:(NSCharacterSet *)otherSet

From Doc:

Modifies the receiver so it contains all characters that exist in either the receiver or otherSet.

like image 95
B.S. Avatar answered Sep 22 '22 23:09

B.S.


For Swift 3:

let fullCharset = aCharset.union(anotherCharset)
like image 40
William Denniss Avatar answered Sep 23 '22 23:09

William Denniss