Vipin
Vipin

Reputation: 4728

How can i append a space in each side of a string?

i have a NSString object named as myString.i need to append a space in each side of my string. can any one tell me the good way to do it?

Upvotes: 0

Views: 1214

Answers (3)

Aman Aggarwal
Aman Aggarwal

Reputation: 3754

Then you can do it in this way.

NSString *s = [[NSString alloc]initWithFormat:@" %@ ",str];

Upvotes: 0

dasdom
dasdom

Reputation: 14063

NSString *myNewString = [NSString stringWithFormat: @" %@ ", myString];

Upvotes: 2

elp
elp

Reputation: 8131

myString = [NSString stringWithFormat:@" %@ ", myString];

Upvotes: 7

Related Questions