2

I have this line of code that is giving me a warning:

result = [result substringToIndex:[result length] - 1];

The warning is:

Incompatible pointer types assigning to 'NSMutableString *' from 'NSString *'

I think I understand what the problem is (my use of the substring returns NSString?) - I just don't know how to fix it. Can someone please enlighten me?

4

2 回答 2

17
result = [[result substringToIndex:[result length] - 1] mutableCopy]

假设结果是 NSMutableString 类。

于 2013-10-23T23:51:26.210 回答
3

在这里找到答案:

[result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];

感谢您的努力;我很感激。标清

于 2013-10-24T15:32:36.983 回答