how to replace space by % in objective c :Iphone
I am getting value in search box from user and storing it in NSstring *searchWord;
I want that when user typed let say "Lady Gaga" then I Replace the 开发者_运维百科space with % just like that searchWord=searchbar.text;
now search word has "lady gaga"
I want to replace it with.
searchword=@"lady%gaga";
You could try this :
NSString *newString = [ @"lady gaga" stringByReplacingOccurrencesOfString:@" " withString:@"%"];
It should work :-)
-[NSString replaceOccurrencesOfString:withString:options:range:]
精彩评论