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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:10:54+00:00 2026-05-26T19:10:54+00:00

I’ve got a custom class (which resembles an NSArray in concept and, hopefully, formatted

  • 0

I’ve got a custom class (which resembles an NSArray in concept and, hopefully, formatted appearance) which has a description formatter.

When the output of the formatter is printed (NSLog) by itself it looks fine, but when it’s included as an element of an NSDictionary description the NSDictionary formatter seems to decide that it’s a character string, not a structure definition, encloses it in quotes, and escapes all of the control characters in the string.

It doesn’t do this for a standard NSArray, of course, so I’m wondering how it decides to treat the string one way vs the other.

Eg, rather than having output that looks like:

theChildren = (
                  {
                      "@meta.type" = "ns3:location";
                      "childNumber" = 0;
                      ...

It looks like:

theChildren = "( \n\t\t {\n\t  \"@meta.type\" = \"ns3:location\";\n\t   \"childNumber\" = 0;
...

Can anyone suggest a way to alter this behavior?

FWIW, I accumulate the description string (with data consisting primarily of the results from calls to NSDictionary description) in an NSMutableString, then do NSString stringFromString at the exit (though I don’t know that that does anything).

Added

I think I found the answer (haven’t checked yet) buried in the NSDictionary writeup:

Discussion

The returned NSString object contains the string representations of
each of the dictionary’s entries. descriptionWithLocale:indent:
obtains the string representation of a given key or value as follows:

If the object is an NSString object, it is used as is.

If the object responds to descriptionWithLocale:indent:, that

method is invoked to obtain the object’s string representation.

If the object responds to descriptionWithLocale:, that method is

invoked to obtain the object’s string representation.

If none of the above conditions is met, the object’s string

representation is obtained by invoking its description method.

Update

Well, turns out they lie. I implemented descriptionWithLocale:indent: and it never gets called.

Update 9/23

Interestingly, if I make my class a subclass of NSArray then NSDictionary calls descriptionWithLocale:indent: and it formats correctly. Sounds like NSDictionary is “cheating” and testing isKindOfClass rather than respondsToSelector, or else is just prejudiced against non-NS stuff.

It’s kind of ugly to have to subclass NSArray, though, in terms of acquiring a lot of behaviors I don’t want to mimic, and carrying extra unused data.

Etc

Another option is to convert the escaped string back to its original. This takes a 31-line procedure to handle the basics (\n, \t, \", and \\). The up-side is that I don’t need to subclass NSArray. The main downside is that this routine must be inserted in any NSLog call that could display my class. Another minor downside is that the escaped strings were wrappered with quote characters I can’t eliminate, but that’s hardly noticeable.

Got it #ifdefed for now — not sure which I’ll pick.

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

    There’s no real answer to this question (the “security feature” of OS X doesn’t appear to affect iOS console writes), but there are these two work-arounds:

    #1: Interestingly, if I make my class a subclass of NSArray then NSDictionary calls descriptionWithLocale:indent: and it formats correctly. Sounds like NSDictionary is “cheating” and testing isKindOfClass rather than respondsToSelector, or else is just prejudiced against non-NS stuff.

    It’s kind of ugly to have to subclass NSArray, though, in terms of acquiring a lot of behaviors I don’t want to mimic, and carrying extra unused data.
    Etc

    #2: Another option is to convert the escaped string back to its original. This takes a 31-line procedure to handle the basics (\n, \t, \”, and \). The up-side is that I don’t need to subclass NSArray. The main downside is that this routine must be inserted in any NSLog call that could display my class. Another minor downside is that the escaped strings were wrappered with quote characters I can’t eliminate, but that’s hardly noticeable.

    (Accepted this answer, even though it’s not the “real” answer, because my accepted % would suffer otherwise. I ask too many difficult questions, I guess.)

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a text area in my form which accepts all possible characters from
i got an object with contents of html markup in it, for example: string

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.