开发者

how to replace space by % in objective c :Iphone

开发者 https://www.devze.com 2023-01-19 02:51 出处:网络
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

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:]

0

精彩评论

暂无评论...
验证码 换一张
取 消