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 8462747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:15:16+00:00 2026-06-10T14:15:16+00:00

I am new to Obj-c. I am adding parameter like text (the text may

  • 0

I am new to Obj-c. I am adding parameter like text (the text may have special characters also)to url. But the url is showing nil, it’s not taking value from string.

For example:

NSString*strUrl=[NSString stringWithFormat:@"hi how@!#$%^^&*()_=+   r u <>,./ where r u"];

NSString *strMainUrl=[NSString stringWithFormat:@"http://google.com/API/index.php action=listIt&data=%@",strUrl];

NSString *encodeStr = [string stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSURL *url=[NSURL URLWithString:encodeStr];

NSLog(@" url is =%@",url);

But the url is showing nil value. It’s not taking “encodeStr” value. How can I solve this problem.Please help me.

I tried with..

NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:str] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0];

and also

strEncode=[strEncode stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

  • 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-06-10T14:15:18+00:00Added an answer on June 10, 2026 at 2:15 pm

    Modified example from here:

    #import <Foundation/Foundation.h>
    
    // In case you're unfamiliar, this is a category, which allows us to add methods
    // to an existing class, even if we didn't create it. It's a nice alternative
    // to subclassing.
    //
    // In this case, we're extending NSString
    @interface NSString (URLEncoding)
    -(NSString *)urlEncodeUsingEncoding:(NSStringEncoding)encoding;
    @end
    
    @implementation NSString (URLEncoding)
    -(NSString *)urlEncodeUsingEncoding:(NSStringEncoding)encoding {
        return (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
                   (CFStringRef)self,
                   NULL,
                   (CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",
                   CFStringConvertNSStringEncodingToEncoding(encoding));
    }
    @end
    
    int main(int argc, char *argv[]) {
        @autoreleasepool 
        {
            NSString *raw = @"hi how@!#$%^^&*()_=+   r u <>,./ where r u";
    
                // note also, that your string omits the '?' in the URL
            NSString *url = [NSString stringWithFormat:@"http://google.com/API/index.php?action=listIt&data=%@",
                        [raw urlEncodeUsingEncoding:NSUTF8StringEncoding]];
    
            NSURL *finalUrl = [NSURL URLWithString:url];
    
            NSLog(@"%@", finalUrl);
        }
    }
    

    Output:

    http://google.com/API/index.php?action=listIt&data=hi%20how%40%21%23%24%25%5E%5E%26%2A%28%29_%3D%2B%20%20%20r%20u%20%3C%3E%2C.%2F%20where%20r%20u
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script which creates a user-defined object like this: obj = new
You'll have to forgive me because i'm still fairly new to Obj-C but i'm
I want to add new obj of JSON like: 128: { Msg: [{ me:
I have a method -(void)myMethod:(MyObject*)obj And I am detaching a new thread [NSThread detachNewThreadSelector:@selector(myMethod)
I would like to specialise a base class by adding new events and methods
I have a hashmap like this public HashMap <String,People> valueHashMap = new Hashmap(); Here
I have a container class for adding some properties to standard data types like
<script type=text/javascript> var a = new Array(); function obj(type, value) { this.type = type;
What are the differences between these two codes in JavaScript? var obj = new
// // To Throw void PrintType(object obj) { if(obj == null) { throw new

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.