开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜