0

我在Incompatible integer to pointer conversion sending 'unichar' (aka 'unsigned short') to parameter of type 'NSString *'此代码的最后一行收到错误消息。

NSMutableString *sp = [[NSMutableString alloc] initWithString:@"             "];
NSArray *deals=@[@[sp, sp, sp, sp], @[sp, sp, sp, sp]];
NSString* suits = @"NESW";
[deals[0][3] replaceCharactersInRange:NSMakeRange(1, 1) withString:[suits characterAtIndex:2]];
4

1 回答 1

2

As the error says, characterAtIndex: returns a unichar while replaceCharactersInRange:withString: needs an NSString. Try substringWithRange:NSMakeRange(2,1) instead if you want an NSString with the character at index 2.

于 2013-02-08T00:48:28.447 回答