Hi just starting to learn this language, more of a javascript/PHP guy…
I can’t seem to figure out the proper syntax and after searching the internets for a straight answer or explanation I decided to bother you SOF community:
This works as I want it to work:
self.displaysTheStack.text = [self.displaysTheStack.text stringByAppendingString:@" "];
self.displaysTheStack.text = [self.displaysTheStack.text stringByAppendingString:operation];
self.displaysTheStack.text = [self.displaysTheStack.text stringByAppendingString:@" "];
I wanted to know if I could do the same thing in less lines something like:
NSString *displayTheArrayText = [NSString stringWithFormat:@" ",operation,@" "];
self.displaysTheStack.text = [self.displaysTheStack.text stringByAppendingString:displayTheArrayText];
When I do it this way I get the Two @” ” (spaces) but “operation” doesn’t show up: why and how do I write the latter command properly?
stringWithFormat:uses C-style formats similar to those used by printfyou probably want something like that:
have a look at Formatting String Objects