diff options
Diffstat (limited to 'Foundation/GTMNSString+URLArguments.m')
-rw-r--r-- | Foundation/GTMNSString+URLArguments.m | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Foundation/GTMNSString+URLArguments.m b/Foundation/GTMNSString+URLArguments.m index 90c65c5..e785c5e 100644 --- a/Foundation/GTMNSString+URLArguments.m +++ b/Foundation/GTMNSString+URLArguments.m @@ -6,9 +6,9 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -18,23 +18,25 @@ #import "GTMNSString+URLArguments.h" -#import "GTMDefines.h" - @implementation NSString (GTMNSStringURLArgumentsAdditions) -- (NSString*)gtm_stringByEscapingForURLArgument { +- (NSString *)gtm_stringByEscapingForURLArgument { // Encode all the reserved characters, per RFC 3986 // (<http://www.ietf.org/rfc/rfc3986.txt>) - CFStringRef escaped = + CFStringRef escaped = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, (CFStringRef)@"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8); - return GTMCFAutorelease(escaped); +#if defined(__has_feature) && __has_feature(objc_arc) + return CFBridgingRelease(escaped); +#else + return [(NSString *)escaped autorelease]; +#endif } -- (NSString*)gtm_stringByUnescapingFromURLArgument { +- (NSString *)gtm_stringByUnescapingFromURLArgument { NSMutableString *resultString = [NSMutableString stringWithString:self]; [resultString replaceOccurrencesOfString:@"+" withString:@" " |