Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Remove double spaces in string xcode

How would I remove double spaces in a string in xcode?

E.g Treehouse is great to Treehouse is great

1 Answer

Alex Hedley
Alex Hedley
16,381 Points
NSString *str = @"This is a string";

str = [str stringByReplacingOccurrencesOfString:@"string" withString:@"duck"];

Where do I put this?

Alex Hedley
Alex Hedley
16,381 Points

Where are you getting the string you want to amend?

Are you storing this in a variable?

I am trying to detect it in a label when clicking a button

All I have done is

-(IBAction)button{ Label.text=@"Hello world" }