如何传递unichar对象?

use*_*795 0 iphone cocoa objective-c

我需要将一个字符传递给第一行.2:我试过的第一种方法,

1) unichar dicttxt = [[myword lowercaseString] characterAtIndex:0];

   2) fileName = [[NSBundle mainBundle] pathForResource:dicttxt ofType: @"txt"];
Run Code Online (Sandbox Code Playgroud)

我试过的第二种方法,

NSString *dicttxt = [[myword lowercaseString] characterAtIndex:0];

fileName = [[NSBundle mainBundle] pathForResource:dicttxt ofType: @"txt"];
Run Code Online (Sandbox Code Playgroud)

两种方法都提示错误 Make pointer from integer without a cast.

dre*_*lax 6

而不是使用字符,使用:

NSString *dicttxt = [[myword lowercaseString] substringWithRange:NSMakeRange(0, 1)];
fileName = [[NSBundle mainBundle] pathForResource:dicttxt ofType:@"txt"];
Run Code Online (Sandbox Code Playgroud)

或者(我完全忘记了这个方法),以下功能上与上述相同,但更简洁:

NSString *dicttxt = [[myword lowercaseString] substringToIndex:1];
fileName = [[NSBundle mainBundle] pathForResource:dicttxt ofType:@"txt"];    
Run Code Online (Sandbox Code Playgroud)

这些只会工作:

  1. myword 长度至少为1.
  2. myword 不是以复合字符开头(即"café"很好,但"über"可能不是).