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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:36:17+00:00 2026-06-13T18:36:17+00:00

I have a short method for URL encoding NSStrings. – (NSString *)urlEncodeValue:(NSString *)strToEncode {

  • 0

I have a short method for URL encoding NSStrings.

- (NSString *)urlEncodeValue:(NSString *)strToEncode
{
    NSLog(@"Testing strToEncode: %@", strToEncode);
    NSString *encodedString = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)strToEncode, NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingUTF8));
    NSLog(@"Testing strToEncode: %@", strToEncode);
    NSLog(@"Testing urlEncode: %@", encodedString);
    return encodedString;
}

The NSLog lines are for debugging and will be commented out when I’ve solved this problem.

Trying it with the string, Testing URLencode % "hmm", works as expected.

2012-11-03 06:44:02.140 FoodyU[23223:c07] Testing strToEncode: Testing URLencode % "hmm" 
2012-11-03 06:44:02.141 FoodyU[23223:c07] Testing strToEncode: Testing URLencode % "hmm" 
2012-11-03 06:44:02.142 FoodyU[23223:c07] Testing urlEncode: Testing%20URLencode%20%25%20%22hmm%22%20

Trying it with the following JSONarray does not:

2012-11-03 06:44:02.142 FoodyU[23223:c07] Testing strToEncode: (
        {
        dataMode = fastUpload;
        dateCreated = "373599360.708794";
        dateModified = "373599414.702938";
        dateSynced = "373632241.82217";
        entityName = CommodityTypes;
        myName = " Commodity Type";
        sortKey = 99;
        username = adamekPhoneDev;
        uuidKey = "338A0507-355F-4DF5-97A4-C0F1FF651D6F";
    },
        {
        dataMode = fastUpload;
        dateCreated = "373599366.851905";
        dateModified = "373599382.473983";
        dateSynced = "373632241.82217";
        entityName = CommodityTypes;
        myName = "Anoth Type";
        sortKey = 90;
        username = adamekPhoneDev;
        uuidKey = "6C64E7C6-4C57-4DFC-BECA-D2AB2339E204";
    }
)
2012-11-03 06:44:02.143 FoodyU[23223:c07] -[__NSArrayM length]: unrecognized selector sent to instance 0x9946ae0
2012-11-03 06:44:02.145 FoodyU[23223:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM length]: unrecognized selector sent to instance 0x9946ae0'
*** First throw call stack:
(0x1ffb012 0x1690e7e 0x20864bd 0x1feabbc 0x1fea94e 0x1f76090 0x1feba1d 0x284d8 0x28a52 0x251cb 0x21c18 0x219b5 0x6878d5 0x687b3d 0x108ee83 0x1fba376 0x1fb9e06 0x1fa1a82 0x1fa0f44 0x1fa0e1b 0x24267e3 0x2426668 0x5d865c 0x224d 0x2175)
libc++abi.dylib: terminate called throwing an exception

Logging the string before conversion works; it is a nicely formatted JSON string. Then it crashes with that error message from somewhere within NSString *encodedString = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)strToEncode, NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingUTF8));

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-06-13T18:36:18+00:00Added an answer on June 13, 2026 at 6:36 pm

    [__NSArrayM length]: unrecognized selector sent to instance 0x9946ae0

    You are putting a NSArray where a NSString is expected. It would be a good idea to serialize the JSON data into a string first.

    Why are you URL-encoding JSON data, anyway?

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

Sidebar

Related Questions

i have a short script where i'm trying to grab data from a URL
I have this code (two classes) class url { private $profile_id; private $short; public
I'd like to use the somelist.sort() method to do this if possible. I have
I have a method invoking bean which calls a method to perform some sort
I am coding a messaging system and I don't want to have short IDs
I have a short access/mySQL question. I have a mapping table on the format
I have a short question i have wrote this in java. Old code: class
I have a short question. Im my current project I'm using LINQ-to-SQl. That is
I have a short version of the question: I start a thread like that:
I have a short question, let's assume I have a TabBarController with 3 Tabs

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.