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."
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."
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.