
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Replace 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”.
Advertisements