

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- 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
- How to get own phone number by standard APIs from iPhone SDK?
- String function to replace nth occurrence of a character in a string JavaScript
- C# program to replace n-th character from a given index in a string
- How to replace a character in a MySQL table?
- Replace the Substring for Balanced String in C++
- How to URL encode a string (NSString) in iPhone?
- How to replace a particular character in a MySQL column?
- Java Program to replace all occurrences of a given character in a string
- C# Program to replace a character with asterisks in a sentence
- How to replace line breaks in a string in C#?
- How to find and replace string in MySQL database for a particular string only?
Advertisements