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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:47:09+00:00 2026-05-30T14:47:09+00:00

-(void)resultaat{ for(id key in [addressbook allKeys]){ NSLog(@\n%@ \n-\n %@ , key,[addressbook objectForKey:key] ); }

  • 0
    -(void)resultaat{
    for(id key in [addressbook allKeys]){
        NSLog(@"\n%@ \n-\n  %@ ", key,[addressbook objectForKey:key]  );
    } 
}

I have a method resultaat which loops over a mutable dictionary, this dictionary has the alfabet as keys and one or more person object(s) in an array as value. The personobject has a name, multiple emails, multiple phone numbers.

In the person class I used description to join the mails and phone numbers into comma-separated strings and output the results.

-(NSString *) description {

    NSString *joinedmails = [mails componentsJoinedByString:@","];
    NSString *joinedtelnrs = [telnrs componentsJoinedByString:@","];

    return [NSString stringWithFormat:@"\n Naam: %@ \n email: %@ \n telefoonnr: %@",naam,joinedmails, joinedtelnrs];
}

This works fine if I do e.g.

NSLog(@"%@",waldo);

I get

  2012-02-27 17:39:59.355 Adresboek[5162:503] 
     Naam: Waldo Odlaw 
     email: waldo.odlaw@waldo.com,waldo.odlaw@gmail.com 
     telefoonnr: 123456789,987654321

But when I loop over the entire adressboek the person object is not returned like above

-(void)resultaat{
for(id key in [addressbook allKeys]){
    NSLog(@"\n%@ \n-\n  %@ ", key,[addressbook objectForKey:key]  );
} 

}

    2012-02-27 17:39:59.407 Adresboek[5162:503] 
    w 
    -
      (
        "\n Naam: Waldo Odlaw \n email: waldo.odlaw@waldo.com,waldo.odlaw@gmail.com \n telefoonnr: 123456789,987654321",
        "\n Naam: Wuno Odlaw \n email: wuno.odlaw@wuno.com,wuno.odlaw@gmail.com \n telefoonnr: 2468101214,1412108642"
    ) 
    2012-02-27 17:39:59.408 Adresboek[5162:503] 
    j 
    -
      (
    ) 

How can I format my output.

  • 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-30T14:47:11+00:00Added an answer on May 30, 2026 at 2:47 pm

    The documentation for the NSArray class’s -description method says it will return a description of the array formatted as a property list. I suspect that its implementation is taking the -description from your PersonObject and converting all of the newline characters to a ‘/’ character followed by a ‘n’ character. That way it shows the newline in your strings while still remaining a valid property list format.

    To get what you want I think you will need to manually loop through the array to build up a string that looks the way you want it. If you want to print the whole address book using the %@ format specifier, then you would probably need to subclass NSArray and provide your own -description method for the arrays you store in your dictionary.

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

Sidebar

Related Questions

I have a simple program which loops through a resultset when a button is
This simple .c file: #include <unistd.h> void test() { char string[40]; gethostname(string,40); } ...
I have a setup that looks like this. class Checker { // member data
I have been working on a Java project in which the reports will be
I have a class which makes a url request and stores data from that
I am working on an android app in which i have to fetch data
I have a jdbc code in which I have used transaction management in code.
I have a managed bean which gets list of settings and values from database
I have a winforms app which I have placed my own custom labels on
I have a method that i want to mock that takes an array as

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.