NSCharacterSet - append another character set

半世苍凉 提交于 2019-12-08 14:52:50

问题


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?


回答1:


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.




回答2:


For Swift 3:

let fullCharset = aCharset.union(anotherCharset)


来源:https://stackoverflow.com/questions/18809149/nscharacterset-append-another-character-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!