0

Here is my code

CFStringRef escapedStr;

  escapedStr = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                       originalString,
                                                       leaveUnescaped,
                                                       kCharsToForceEscape,
                                                       kCFStringEncodingUTF8);

The Error is:

CFURLCreateStringByAddingPercentEscapes is deprecated in ios 9.0, use stringByAddingPercentEncodingWithAllowedCharacters which always uses recommended UTF-8 settings.

Could somebody help with how to replace CFURLCreateStringByAddingPercentEscapes with stringByAddingPercentEncodingWithAllowedCharacters in above code.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Umar
  • 17
  • 6
  • Why would you ask a question that you know is a duplicate? Anyway, it's almost always nonsensical to want to percent-encode entire strings. Read (Apple's release notes discussion)[https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/#10_11URL] about this subject. – Ken Thomases May 28 '16 at 10:18

1 Answers1

-1

use below code maybe its helped

CFStringRef escapedStr;
escapedStr = (__bridge CFStringRef)([str stringByAddingPercentEncodingWithAllowedCharacters:[kCFAllocatorDefault,originalString,leaveUnescaped,kCharsToForceEscape,kCFStringEncodingUTF8]]);// here str is your NSString
ios_dev
  • 1,025
  • 15
  • 27
  • Thanks for your help.I am getting these 2 new errors after putting above code 1.Expression Result unusual 2.Expected Identifier – Umar May 29 '16 at 09:45