11 May 2012

Removing Spaces from Text

Found this on the web and was very helpful when I implemented the Weather App. This is helpful for removing spaces from a text.

I implemented the following line in my (IBAction)refreshView in my MainViewController.m file:
 NSString *noSpaceLocation = [nameLabel.text stringByReplacingOccurrencesOfString:@" " withString:@""];

Then I just called the following under the same (IBAction)refreshView:
[self.forecast queryService:noSpaceLocation withParent:self];

I did this because I implemented a Flip Side Method for the "user" to change cities but was running into trouble with the "user" putting spaces into the UITextField.

This may be helpful for the final project.
-Ben

1 comment: