1
我想在Swift中定義一個包含[A-Z](注意雙字節,不是[A-Z])的NSCharacterSet
。嘗試在Swift中定義一個帶有Unicode字符的自定義NSCharacterSet
什麼是正確的語法來做到這一點?下面我在Objectiv C中工作的代碼似乎並不像Swift那麼容易。
NSRange alphaDoubleByteRange;
NSMutableCharacterSet *alphaDoubleByteLetters;
alphaDoubleByteRange.location = (unsigned int)[@"A" characterAtIndex:0];
alphaDoubleByteRange.length = 26;
alphaDoubleByteLetters = [[NSMutableCharacterSet alloc] init];
[alphaDoubleByteLetters formUnionWithCharacterSet:[NSCharacterSet characterSetWithRange:alphaDoubleByteRange]];
// Now alphaDoubleByteLetters contains what I want.
有趣!那是有效的。謝謝。 – Michel