Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6198443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:59:53+00:00 2026-05-24T03:59:53+00:00

I have a category class for NSString. @implementation NSString (URLEncode) – (NSString *)URLEncodedString {

  • 0

I have a category class for NSString.

@implementation NSString (URLEncode)

- (NSString *)URLEncodedString
{
    __autoreleasing NSString *encodedString;

    NSString *originalString = (NSString *)self;    
    encodedString = (__bridge_transfer NSString * )
            CFURLCreateStringByAddingPercentEscapes(NULL,
                                (__bridge CFStringRef)originalString,
                                NULL,
                                (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                kCFStringEncodingUTF8);
    return encodedString;
}

Am I using the correct bridge transfers for ARC and the new LLVM?

The original code:

- (NSString *)URLEncodedString
    NSString *encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
                                (CFStringRef)self,
                                NULL,
                                (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                kCFStringEncodingUTF8);
    return [encodedString autorelease];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:59:55+00:00Added an answer on May 24, 2026 at 3:59 am

    As mentioned in the comments, I think it’s fine to talk about ARC and the contents of Automatic Reference Counting here.

    __autoreleasing is not meant to be used like that. It’s used for passing indirect object references (NSError**, etc). See 4.3.4 Passing to an out parameter by writeback.

    According to 3.2.4 Bridged casts, the __bridge_transfer is correct as the CFURLCreateStringByAddingPercentEscapes function returns a retained object (it has “create” in its name). You want ARC to take ownership of the returned object and insert a release (or autorelease in this case) to balance this out.

    The __bridge cast for originalstring is correct too, you don’t want ARC to do anything special about it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have stack category for NSMutableArray that I use in Class A @implementation NSMutableArray
i have two models: class Category has many :jobs end class Job belongs_to :category
I have three models: class Address < ActiveRecord::Base has_many :jobs end class Category <
For edit home status of category I have a link: <span class=\ha\ title=\Active in
I have products as an embedded document inside the category class as shown below:
I have 2 models which have a has_and_belongs_to_many relation: class Category < ActiveRecord::Base has_and_belongs_to_many
I have the following Django 1.2 models: class Category(models.Model): name = models.CharField(max_length=255) class Article(models.Model):
I have a two models: class Category(models.Model): pass class Item(models.Model): cat = models.ForeignKey(Category) I
I have a POCO class as follows public class Category { public int ID
im have model Category. class Category < ActiveRecord::Base has_ancestry :cache_depth => true, :depth_cache_column =>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.