-1

I ve got a string url where i need to append a string at the very end of the url.but the problem is there are extra percentage signs and getting warning "Format specifies double but the argument has of type NSString".how to solve this is issuse. Below is the code

boxOfficeWeekly = [ServerApi getCollections:[NSString stringWithFormat:@"http://www.boxofficeindia.co.in/weekly-collections-%E2%80%93-box-office/%@",selectedPickerValue]
Eiko
  • 25,601
  • 15
  • 56
  • 71
user578386
  • 1,061
  • 3
  • 14
  • 37

2 Answers2

0

You need to put just double %% symbol intead of single % symbol. And use this string

  boxOfficeWeekly = [ServerApi getCollections:[NSString stringWithFormat:@"http://www.boxofficeindia.co.in/weekly-collections-%%E2%%80%%93-box-office%@",selectedPickerValue]
Dharmbir Singh
  • 17,485
  • 5
  • 50
  • 66
0

you need to double the % signs in nsstring to escape them if they are not a parameter like this %% or use the

- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding

method for the first part of your string wich will automatically escape all % signs https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/stringByAddingPercentEscapesUsingEncoding

in your sample it would be something like this:

 Nsstring *url = [@"http://www.boxofficeindia.co.in/weekly-collections-%E2%80%93-box-office/" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
 boxOfficeWeekly = [ServerApi getCollections:[NSString stringWithFormat:@"%@%@, url, selectedpickervalue]];
jonas vermeulen
  • 1,235
  • 5
  • 23
  • 40
  • could u help me use the above funtionality on the code given..coz adding %% helps me get rid of the warning but crashes.since the url is a html feed url..adding an extra percentage returns nil – user578386 Sep 12 '13 at 13:25
  • @user578386 i've edited my answer with an example, can you please try it out? – jonas vermeulen Sep 12 '13 at 13:34