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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:37:55+00:00 2026-06-07T18:37:55+00:00

I’m querying a Facebook public JSON feed. I’m getting an error: -[__NSCFString objectForKey:]: unrecognized

  • 0

I’m querying a Facebook public JSON feed. I’m getting an error:

-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x9146b90 2012-07-11 10:32:25.536 iB Top 50[1789:16a03]

I’m trying to parse the tag “message” and “picture” for the object with

"id": "108448345915250_320180984741984"

Please help me.

Example JSON:

{
"data": [
  {
     "id": "108448345915250_320181064741976",
     "from": {
        "name": "Amitabh Bachchan",
        "category": "Actor/director",
        "id": "108448345915250"
     },
     "story": "Amitabh Bachchan edited his Website and Location.",
     "story_tags": {
        "0": [
           {
              "id": 108448345915250,
              "name": "Amitabh Bachchan",
              "offset": 0,
              "length": 16,
              "type": "page"
           }
        ]
     },
     "type": "status",
     "created_time": "2012-07-10T05:30:10+0000",
     "updated_time": "2012-07-10T05:30:10+0000",
     "comments": {
        "count": 0
     }
  },
  {
     "id": "108448345915250_320180984741984",
     "from": {
        "name": "Amitabh Bachchan",
        "category": "Actor/director",
        "id": "108448345915250"
     },
     "message": "Singing in the praises of this new venture \u2026 metal mike and all \u2026",
     "picture": "http://photos-d.ak.fbcdn.net/hphotos-ak-snc7/293763_320180974741985_675837103_s.jpg",
     "link": "http://www.facebook.com/photo.php?fbid=320180974741985&set=a.126948684065216.26767.108448345915250&type=1&relevant_count=1",
     "icon": "http://static.ak.fbcdn.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif",
     "type": "photo",
     "object_id": "320180974741985",
     "created_time": "2012-07-10T05:29:34+0000",
     "updated_time": "2012-07-10T,
          "shares": {
        "count": 41
     },
     "likes": {
        "data": [
           {
              "name": "Amir Samy",
              "id": "100000377429168"
           },
           {
              "name": "Rashi Shrivastava",
              "id": "100001002346693"
           },
           {
              "name": "Satish Wakpaijan",
              "id": "100002129452923"
           },
           {
              "name": "Sushil Kumar",
              "id": "100002105808620"
           }
        ],
        "count": 300
     },
     "comments": {
        "count": 45
     }
  },
  ...

iOS Code:

jsonurl=[NSURL URLWithString:@"https://graph.facebook.com/TheAmitabhBachchan/posts?access_token=AcessToken"];

jsonData=[[NSString alloc]initWithContentsOfURL:jsonurl];

jsonArray = [jsonData objectFromJSONString]; 

items = [jsonArray objectForKey:@"data"];

story = [NSMutableArray array];
title = [NSMutableArray array];
picture = [NSMutableArray array];

for (NSDictionary *item in items )
{
    [story addObject:[item objectForKey:@"message"]];
   /* [title addObject:[item objectForKey:@"name"]];
    [picture addObject:[item objectForKey:@"picture"]];*/
}
  • 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-07T18:37:57+00:00Added an answer on June 7, 2026 at 6:37 pm

    In the line :

    jsonArray = [jsonData objectFromJSONString];
    

    you are fetching the object from the obtained JSON string. You have to convert theJSON string to its correct value. Use SBJSON parser for this.

    It is not about that your jsonArray or item is a dictionary and your store the values in dictionary.Its about what does the following methods return :

    [jsonData objectFromJSONString];
    [item objectForKey:@"message"];
    

    Are both(jsonArray and item) dictionaries? One of them is NSString as your error says.Parse the JSON value correctly.

    Then check this :

    NSString *sss = @"https://graph.facebook.com/TheAmitabhBachchan/posts?access_token=393411130717153%7C1HFhZAByEHp89q6CPECJTFzuzfg";
    NSURL * jsonurl=[NSURL URLWithString:[sss stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSData* data = [NSData dataWithContentsOfURL: jsonurl];
    NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data 
                                                         options:kNilOptions 
                                                           error:nil];
    NSArray *items = [json objectForKey:@"data"];
    // NSDictionary *item = [items objectAtIndex:1];
    
    NSMutableArray *story = [NSMutableArray array];
    
    for (NSDictionary *item in items )
    {
    
        if([item objectForKey:@"message"] || [item objectForKey:@"message"] != nil || [[item objectForKey:@"message"] length]>0){
            [story addObject:[item objectForKey:@"message"]];
        }
    
    }             
    

    Not each of your dictionary contains the key – “message”.It is present in the second dictionary in the array.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.