GTMNSString+URLArguments.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // GTMNSString+URLArguments.h
  3. //
  4. // Copyright 2006-2008 Google Inc.
  5. //
  6. // Licensed under the Apache License, Version 2.0 (the "License"); you may not
  7. // use this file except in compliance with the License. You may obtain a copy
  8. // of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // Unless required by applicable law or agreed to in writing, software
  13. // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  14. // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  15. // License for the specific language governing permissions and limitations under
  16. // the License.
  17. //
  18. #import <Foundation/Foundation.h>
  19. /// Utilities for encoding and decoding URL arguments.
  20. @interface NSString (GTMNSStringURLArgumentsAdditions)
  21. /// Returns a string that is escaped properly to be a URL argument.
  22. ///
  23. /// This differs from stringByAddingPercentEscapesUsingEncoding: in that it
  24. /// will escape all the reserved characters (per RFC 3986
  25. /// <http://www.ietf.org/rfc/rfc3986.txt>) which
  26. /// stringByAddingPercentEscapesUsingEncoding would leave.
  27. ///
  28. /// This will also escape '%', so this should not be used on a string that has
  29. /// already been escaped unless double-escaping is the desired result.
  30. ///
  31. /// NOTE: Apps targeting iOS 8 or OS X 10.10 and later should use
  32. /// NSURLComponents and NSURLQueryItem to create properly-escaped
  33. /// URLs instead of using these category methods.
  34. - (NSString*)gtm_stringByEscapingForURLArgument NS_DEPRECATED(10_0, 10_10, 2_0, 8_0, "Use NSURLComponents.");
  35. /// Returns the unescaped version of a URL argument
  36. ///
  37. /// This has the same behavior as stringByReplacingPercentEscapesUsingEncoding:,
  38. /// except that it will also convert '+' to space.
  39. - (NSString*)gtm_stringByUnescapingFromURLArgument NS_DEPRECATED(10_0, 10_10, 2_0, 8_0, "Use NSURLComponents.");
  40. @end