NSMutableString *mSt1 = [[NSMutableString alloc] stringWithString:asong.at];
NSMutableString *mSt = [[NSMutableString alloc] stringWithString:[mSt1 substringWithRange: NSMakeRange (0, 2)]];
NSMutableString *mSt2 = [[NSMutableString alloc] stringWithString:[mSt1 substringWithRange: NSMakeRange (5, 2)]];
NSMutableString *str = [mSt appendString:mSt2];
[songsHrs addObject:str];
[mSt release];
[开发者_JS百科mSt1 release];
[mSt2 release];
getting the error at line no.4 error: void value not ignored as it ought to be
help me out please...
[mSt appendString:mSt2];
This method has a return type of void
. It modifies the NSMutableString
you call it on (mSt
in this case), but returns nothing.
So don't expect a return value. Delete the NSMutableString *str
and just use it directly.
[songHrs addObject:mSt];
Since the string is mutable, it simply changes itself in place. No need to save the result in a separate variable. In fact, this is the entire point of using NSMutableString
instead of NSString
.
Besides what Squeegy already wrote about appending, your lines 1, 2 and 3 seem also broken - you should call initWithString and not stringWithString, or use stringWithString but no alloc. The whole construct is messy though and doesn't really make sense - but this is for testing purpose probably.
精彩评论