我在此代码的最后一行收到错误消息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]];
答案 0 :(得分:2)
如错误所示,characterAtIndex:
返回unichar而replaceCharactersInRange:withString:
需要NSString。如果您想要一个索引为2的NSString,请尝试使用substringWithRange:NSMakeRange(2,1)
。