unichar and NSString - how interchangeable are these?

后端 未结 3 1203
鱼传尺愫
鱼传尺愫 2020-12-13 04:08

There is an NSString method -characterAtIndex: which returns an unichar.

  • (unichar)characterAtIndex:(NSUInteger)index
3条回答
  •  情话喂你
    2020-12-13 04:38

    Another option is to use the class method:

    + (id)stringWithCharacters:(const unichar *)characters length:(NSUInteger)length;
    

    So just using:

    yourString = [NSString stringWithCharacters: &yourChar length: 1];
    

    The yourChar parameter must be a pointer.

提交回复
热议问题