Newbie here. In the following code:
+ (NSString *)descriptionOfProgram:(id)program
{
NSMutableArray *mutableCopyOfProgram = [program mutableCopy];
NSString *descr = @"";
for (int i=0; i<mutableCopyOfProgram.count; i++)
{
descr = [descr stringByAppendingString:(@"%@",[mutableCopyOfProgram objectAtIndex:i])];
}
return descr;
}
I keep getting an “expression result unused” warning on the code in the loop. But how can that be, when in the next line I return the expression result?
The warning you get is because you should use
stringByAppendingFormat:method instead ofstringByAppendingString:. Anyway, I would recommend usingNSMutableStringfor building a string. Also, it’s better to use[mutableCopyOfProgram count]instead ofmutableCopyOfProgram.count. The following code should work for you: