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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:43:56+00:00 2026-05-28T17:43:56+00:00

I use JSON for implementing Facebook in an app and I’m just making my

  • 0

I use JSON for implementing Facebook in an app and I’m just making my code ARC-friendly. However, when I make lines such as this one

CFStringAppendCharacters((CFMutableStringRef)json, &uc, 1);

become

CFStringAppendCharacters((__bridge CFMutableStringRef)json, &uc, 1);

my app is no longer able to pull my photo albums (I allow the user to log into Facebook and I then display his albums in order for him/her to get a picture to later use in the app).

This is the entire code that is not appreciated by ARC – (could anyone give me a hint how to bridge it please?)

NSString* escaped_value = (NSString *)CFURLCreateStringByAddingPercentEscapes(
                              NULL, /* allocator */
                              (CFStringRef)value,
                              NULL, /* charactersToLeaveUnescaped */
                              (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                              kCFStringEncodingUTF8);

Does anyone know how I could port the JSON framework for ARC use?

  • 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-28T17:43:57+00:00Added an answer on May 28, 2026 at 5:43 pm

    I see in your comment that you just decided to go with NSJSONSerialization, that will definitely work. But to actually answer your question.

    Using the __bridge cast is easy when you think about the memory management involved. __bridge just casts without doing any memory management operations for you; __bridge_transfer also casts, but it decrements the retain count of the object being casted. So with that in mind, your function call can be broken down like so:

    CFStringRef originalValue = (__bridge CFStringRef)value;// Only __bridge required because ownership not changing
    CFStringRef escapeChars = (CFStringRef)@"!*'();:@&=+$,/?%#[]";// __bridge not required for string literal
    CFStringRef escaped_CFString = CFURLCreateStringByAddingPercentEscapes(NULL, originalValue, NULL, escapeChars, kCFStringEncodingUTF8);// returns a CFStringRef that YOU own.
    NSString *escaped_value = (__bridge_transfer NSString *)escaped_CFString; // __bridge_transfer tells the compiler to send a release call to escaped_CFString.
    

    Now that you see what’s happening you can safely stack the calls like this:

    NSString* escaped_value = (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,(__bridge CFStringRef)value,NULL,(CFStringRef)@"!*'();:@&=+$,/?%#[]",kCFStringEncodingUTF8);
    

    Note that this method is still not that reliable. A more complete solution can be found in Dave DeLong’s answer to this question.

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

Sidebar

Related Questions

I usually use JSON with jQuery to just return a string with html. However,
I'm making pretty heavy use of JSON parsing in an app I'm writing. Most
I'm implementing the Graph API in Facebook to retrieve data as JSON from an
I would like to use JSON, however, the security issues related to using JSON
I use json data with jquery... I have filepaths in json and i am
I know how to use JSON to create objects, but there doesn't seem to
Why should I use JSON with ASP.NET? Can you give a practical example? I
I started to use Json.NET to convert a string in JSON format to object
I am trying to use JSON to populate a div, so I basically run
i'm trying to use json_decode to combine a few json objects and then re-encode

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.