-2

I have a issue that is popping up and it is probably a syntax issue:

- (void)extracted_method:(NSString **)tempDir_p
{
  *tempDir_p = [*tempDir_p stringByAddingPercentEscapesUsingEncoding: 
  NSASCIIStringEncoding];
}

Im getting the error, 'stringByAddingPercentEscapesUsingEncoding:' is deprecated: first deprecated in iOS 9.0

Anyone?

Thanks Paul

Ok I changed things abit and came up with this:

(tempDir_p *)stringByAddingPercentEncodingWithAllowedCharacters: 
(NSASCIIStringEncoding *)  ;

still have the same error message...

btw, I am relatively new to this so I apologize if I am upsetting a few people here. 48 and back in school..

  • You need to pass in an NSCharacterSet instead of the encoding. See the link in my answer below for more info. – koen Apr 23 '17 at 22:48

2 Answers2

0

If you search for that method in the documentation, you will see this:

Use stringByAddingPercentEncodingWithAllowedCharacters: instead.

So adjust your code, and your warning will go away.

More info: https://developer.apple.com/reference/foundation/nsstring/1411946-stringbyaddingpercentencodingwit?language=objc

koen
  • 5,383
  • 7
  • 50
  • 89
0

deprecated is not a syntax issue; the compiler rather tells you that a particular message should not be used from a particular iOS-version on. For details, confer, for example, this SO answer (and upvote that answer if applicable).

Community
  • 1
  • 1
Stephan Lechner
  • 34,891
  • 4
  • 35
  • 58