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

  • Home
  • SEARCH
  • 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 944161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:32:55+00:00 2026-05-15T22:32:55+00:00

I just started Objective-C recently, and this has once again gotten me to the

  • 0

I just started Objective-C recently, and this has once again gotten me to the point of asking SO for help. I need to rewrite this method so that I can call it using [self URLEncodedString];

This is what the method currently looks like –

- (NSString *)URLEncodedString {
      NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR("!*'();:@&=+$,/?%#[]"), kCFStringEncodingUTF8);
      [result autorelease];
      return result;
}

But I can’t call it like [self URLEncodedString]; How can I rewrite it so that it would work for me to be able to call it using [self URLEncodedString];?

P.S. Calling it via [strValue URLEncodedString]; doesn’t work, hence the reason I’m making this post.

Thanks for any help!

  • 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-15T22:32:55+00:00Added an answer on May 15, 2026 at 10:32 pm

    I think what you’re asking for is to create an NSString category which will encode your string.

    You need to create a new set of files, name them something that makes sense (NSString+URLEncoding).

    In the .h file, you’ll need something like this:

    @interface NSString (URLEncoding)
    - (NSString*)URLEncodedString;
    @end
    

    Then in your .m file:

    @implementation NSString (URLEncoding)
    
    - (NSString *)URLEncodedString {
          NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR("!*'();:@&=+$,/?%#[]"), kCFStringEncodingUTF8);
          [result autorelease];
          return result;
    }
    
    @end
    

    When you want to use this method, you’ll need to make sure you import “NSString+URLEncoding.h”.

    You can then do something like this:

    NSString * firstString = @"Some string to be encoded %&^(&(!@£$%^&*";
    NSString * encodedString = [firstString URLEncodedString];
    

    Hope that helps.

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

Sidebar

Related Questions

I have just started programming in Objective-C, I understand it only partially supports method
I just started learning objective c. I have this little problems and questions, hope
I'm a Java guy who is familiar with Swing programming and recently just started
I just started learning Objective-C and OOP ... so I have very stupid question
I just started with Objective-C and I would like to understand the meaning of
I've only just started using C#/VS this past week and wondered how to do
I am just getting started again with Mac development. I am using CoreMIDI which
I've just started learning Objective-C and made a little compass app that will display
I recently started learning Objective-C 2.0, with a book, and I want to know
Hi Just started learning c for uni (usually use objective c) and have run

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.