views:

113

answers:

1

i am getting warning: incompatible Objective-C types assigning 'struct NSString *', expected 'struct NSMutableString *' on this line:-

 Value = [Value stringByAppendingString:str];

I declared Value as

 NSMutableString* Value;

How to rectify this?

+3  A: 

With NSMutableString you can (and should) just do the following:

[Value appendString:str];

-stringByAppendingString indeed returns NSString instance even if it was called on NSMutableString and converting it back to mutable will result in both performance overhead and worse code readability.

P.S. Note also that in objective-c style guidelines variable names should start with lowercase.

Vladimir
"void value not ignored as it ought to be" error i am getting.
Tauquir
Tauquir: `appendString:` doesn't return anything; an NSMutableString responds to that message by appending to itself. That's the difference between `stringByAppendingString:` (works on any string; does not modify existing string; returns new string) and `appendString:` (works only on mutable strings; modifies existing string; does not return anything).
Peter Hosey
On what line do you get this error?
Vladimir