- iOS Tutorial
- iOS - Home
- iOS - Getting Started
- iOS - Environment Setup
- iOS - Objective-C Basics
- iOS - First iPhone Application
- iOS - Actions and Outlets
- iOS - Delegates
- iOS - UI Elements
- iOS - Accelerometer
- iOS - Universal Applications
- iOS - Camera Management
- iOS - Location Handling
- iOS - SQLite Database
- iOS - Sending Email
- iOS - Audio & Video
- iOS - File Handling
- iOS - Accessing Maps
- iOS - In-App Purchase
- iOS - iAd Integration
- iOS - GameKit
- iOS - Storyboards
- iOS - Auto Layouts
- iOS - Twitter & Facebook
- iOS - Memory Management
- iOS - Application Debugging
- iOS Useful Resources
- iOS - Quick Guide
- iOS - Useful Resources
- iOS - Discussion
How to replace a character in Objective-C String for iPhone SDK?
To replace a character in objective C we will have to use the inbuilt function of Objective C string library, which replaces occurrence of a string with some other string that we want to replace it with.
To create a string in objective C we need to write −
NSString *str = @"tutori@als";
Now we have a choice of replacing characters in this string and creating new one, or modify this same string. In this example we will modify this string and print in the next line.
str = [str stringByReplacingOccurrencesOfString:@"@" withString:@""]; NSLog(@”%@”,str);
When we run the above code, str is replaced with “tutorials” which was previously “tutori@als”.
- Related Articles
- How to determine device type (iPhone, iPod Touch) with iPhone SDK?
- C# Program to replace a special character from a String
- C program to replace all occurrence of a character in a string
- Replace Character in a String in Java without using replace() method
- C# program to replace n-th character from a given index in a string
- How to replace a character in a MySQL table?
- How to URL encode a string (NSString) in iPhone?
- Java Program to replace all occurrences of a given character in a string
- How to replace line breaks in a string in C#?
- Replace the Substring for Balanced String in C++
- How to replace a particular character in a MySQL column?
- C# Program to replace a character with asterisks in a sentence
- How to find and replace string in MySQL database for a particular string only?
- How to find a replace a word in a string in C#?