NSCharacterSet - Add a different 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. Add in other words.

I thought this would be the obvious way, but after completing the control space in the IDE and then scrolling through the documents, I could not do anything.

I see how to add all characters from a string. But I need to add characters from another set. I guess I could rebuild the second set if there is a string method.

How can I do it?

+6
source share
2 answers

You are probably using for this method in NSMutableCharacterSet :

 - (void)formUnionWithCharacterSet:(NSCharacterSet *)otherSet 

From the Doc:

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

+14
source

For Swift 3:

 let fullCharset = aCharset.union(anotherCharset) 
+3
source

Source: https://habr.com/ru/post/953848/


All Articles