0

What code could be used to edit parts of an NSString, I want it to make it change "International" to "Intl." and remove the word "Airport" from the string.

Example: "Honolulu International Airport" would become "Honolulu Intl."

dgund
  • 3,459
  • 4
  • 39
  • 64
Jon Sullivan
  • 399
  • 2
  • 5
  • 11
  • 1
    Why don't you read the documentation for NSString and attempt the changes you want. If you have problems ask for help then. – Gary Feb 28 '13 at 03:24

1 Answers1

2

This will replace all occurances of the string "International" with "Intl." within your NSString:

NSString *newString = [initialString stringByReplacingOccurrencesOfString:@"International" withString:@"Intl."];

Also,

What could add even more functionality is an NSMutableString. It carries over all of the functionality of an NSString, but adds mutability, meaning you can remove or replace parts of a string, or add more to it. Here is the Apple documentation for NSMutableString. In addition, you can Google more tutorials for it.

dgund
  • 3,459
  • 4
  • 39
  • 64