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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:34:07+00:00 2026-05-16T18:34:07+00:00

NSDictionary *story = [stories objectAtIndex: indexPath.row]; cell.text=[NSString stringwithFormat:[story objectForKey@message]; i dont knw what exaclty

  • 0
NSDictionary *story = [stories objectAtIndex: indexPath.row];
cell.text=[NSString stringwithFormat:[story objectForKey@"message];

i dont knw what exaclty “message ” contains (what is the meaning of objectForKey@”message“)

EDIT CODE

NSString *key =[appDelegate.books objectAtIndex:indexPath.row];
    //dict y=@"Name";

    NSArray *nameSection = [dict objectForKey:key];


    NSDictionary *story = [nameSection objectAtIndex: indexPath.row];
    cell.text=[NSString stringwithFormat:[story objectForKey:key]];

               NSLog(@"Value Of message: %@", [dict objectForKey:key]);

why my code crashes

  • 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-16T18:34:08+00:00Added an answer on May 16, 2026 at 6:34 pm

    If you are more familiar with Java or C# the code is equivalent to something like this:

    // Assuming stories is declared as: List<Dictionary<string, string> stories;
    
    Dictionary<string, string> story = stories[indexPath.row];
    cell.Text = String.Format(story["message"]);
    

    In Smalltalk-style (and therefore Objective-C too) Object Oriented programming, methods are more like messages to other objects. So a good Objective-C method name should read like an English sentence (Subject-Verb-Object). Because of this working with dictionaries (hash tables) looks like this:

    [myDictionary setObject:@"Value" forKey:@"someKey"];
    [myDictionary objectForKey:@"someKey"]; // == @"Value"
    

    In Java it would be:

    myDictionary.put("someKey", "Value");
    myDictionary.get("someKey"); // == "Value"
    

    Notice how the key (“someKey”) was the first argument in the Java example. In Objective-C you name your arguments with the method name, hence setObject: forKey:. Also notice that in Objective-C strings start with an @ symbol. That’s because Objective-C strings are different from regular C strings. When using Objective-C you almost always use Objective-C’s @ strings.

    In C# there is a special syntax for Dictionaries so it becomes:

    myDictionary["someKey"] = "Value";
    myDictionary["someKey"]; // == "Value"
    

    One important problem that you might encounter if you’re new is the problem of native types.

    In Java to add an int to a Dictionary you used to have to do:

    myDictionary.put("someKey", new Integer(10));
    

    Because the primitive types (int, char/short, byte, boolean) aren’t real Objects. Objective-C has this problem too. So if you want to put an int into a dictionary you must use NSNumber like so:

    [myDictionary setObject:[NSNumber numberForInt:10] 
                     forKey:@"someKey"];
    

    And you pull out the integer like so:

    NSNumber *number = [myDictionary objectForKey:@"someKey"];
    [number intValue]; // == 10
    

    EDIT:

    Your code might be crashing if you have a ‘%’ character in your string, since stringWithFormat is just like NSLog in that it takes many arguments. So if story[“message”] is “Hello” then it’ll work fine without extra arguments but if it’s “Hello %@” you need to add one argument to stringWithFormat.

    NSString *message = @"Hello %@";
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setObject:message forKey:@"message"];
    
    NSString *output = [NSString stringWithFormat:[dict objectForKey:@"message"], @"World!"];
    // output is now @"Hello World!".
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a single NSDictionary object which contains a large number of custom objects.
We want to take XML data and convert it to an NSDictionary object, but
Is there a way to view the key/value pairs of a NSDictionary variable through
I'm trying to figure out how to decide when to use NSDictionary or NSCoder/NSCoding?
I'm building an iPhone app with a UITableView. On selecting a row, I'd like
I'm building an iPhone application with a UITableView. On selecting a row a web
I'm developing an iPhone application. I use a NSDictionary to store city's names as
My issue is then I retrieve my NSArray of Store objects, all my NSString
I think I understand the error message: CoreData could not fulfill a fault, but
Say I have a property list that I store into an NSDictionary . An

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.