characterAtIndex:
Posted learning-materials
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了characterAtIndex:相关的知识,希望对你有一定的参考价值。
Instance Method
characterAtIndex:
Returns the character at a given UTF-16 code unit index.
Language
- Swift
- Objective-C
SDKs
- ios 2.0+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
On This Page
Declaration
- (unichar)characterAtIndex:(NSUInteger)index;
Parameters
index
-
The index of the character to retrieve.
Important
Raises an
NSRangeException
ifindex
lies beyond the end of the receiver.
Return Value
The character at the array position given by index
.
Discussion
You should always use the rangeOfComposedCharacterSequenceAtIndex:
or rangeOfComposedCharacterSequencesForRange:
method to determine character boundaries, so that any surrogate pairs or character clusters are handled correctly.
See Also
Related Documentation
以上是关于characterAtIndex:的主要内容,如果未能解决你的问题,请参考以下文章