Always use NSLog(@"%@", object). Otherwise, you will get a compiler error -> "Potentially unsafe."
To handle strings, consider NSMutableString.
The same code can be written using NSMutableString as,
NSMutableString *foo2 = [[NSMutableString alloc] initWithFormat:@""];
for(int i=0; i < [foo length] ; i++){
[foo2 appendString:@"-"];
}
NSLog(@"%@", foo2);
source
share