Issue with NSMakeCollectable when converting to ARC

后端 未结 1 358
忘掉有多难
忘掉有多难 2021-01-18 17:04

I am trying to convert my code to ARC and I have problem with NSMakeCollectable in the ASIRequest library.

- (NSString*)encodeURL:(NSString *)string
{
    N         


        
相关标签:
1条回答
  • 2021-01-18 17:33

    NSMakeCollectable is no longer required in ARC. You can use CFBridgingRelease here.

    - (NSString*)encodeURL:(NSString *)string
    {
        NSString *newString = CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding([self stringEncoding])));
        // or  NSString *newString = (__bridge_transfer NSString*)(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding([self stringEncoding]));
        if (newString) {
            return newString;
        }
        return @"";
    }
    
    0 讨论(0)
提交回复
热议问题