How to fix warning: Incompatible pointer types assigning to 'NSMutableString *' from 'NSString *'

StackOverflow https://stackoverflow.com/questions/19554418

문제

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?

도움이 되었습니까?

해결책 2

Found the answer here:

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

Thanks for the effort; I appreciate it. SD

다른 팁

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

Assuming result is of class NSMutableString.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top