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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:26:32+00:00 2026-06-15T17:26:32+00:00

I have simple Cocoa application, that parse JSON and pack information of JSON to

  • 0

I have simple Cocoa application, that parse JSON and pack information of JSON to object of Day class.

Day.h.

#import <Foundation/Foundation.h>

@interface Day : NSObject

@property(retain, nonatomic) NSString *dateString;

@end

main.m

import <Foundation/Foundation.h>
import </Users/Admin/Documents/SimpleJsonParser/SBJSON.h>
#import "Day.h"

int main(int argc, const char * argv[])
{

    @autoreleasepool {

        // source json object
        NSString *jsonSource = @"{\"days\":[{\"dateString\":\"10 december\"},{\"dateString\":\"11 december\"}]}";

        SBJsonParser *jsonParser = [[SBJsonParser alloc] init];

        NSError *error = nil;

        NSDictionary *jsonObjects = [jsonParser objectWithString:jsonSource error:&error];

        if(error != nil){
            NSLog([error description]);
        }

        // array of days objects
        NSArray *days = [jsonObjects objectForKey:@"days"];

        // create empty array
        NSMutableArray *daysSource = [[NSMutableArray array] retain];

        for(int i = 0; i < [days count]; i++){

            NSDictionary *day = [days objectAtIndex:i];

            // get dateString
            NSString *dateString = [day objectForKey:@"dateString"];

            // create Day object
            Day* dayObject = [[Day alloc] init];

            dayObject.dateString = dateString;

            NSLog(dayObject.dateString);            

            [daysSource addObject:day];
        }

        NSUInteger temp = [daysSource count];
        NSLog(@"Temp is %lu", temp);

        Day *myDay = [daysSource objectAtIndex:0];

        NSString *dateStringTemp = myDay.dateString;
    }
}

And when I run this code, I get this error:

2012-12-11 14:09:50.867 SimpleJsonParser[577:303] -[__NSDictionaryM dateString]: unrecognized selector sent to instance 0x10010e4d0
2012-12-11 14:09:50.869 SimpleJsonParser[577:303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM dateString]: unrecognized selector sent to instance 0x10010e4d0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff90a2e0a6 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff8c6713f0 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff90ac46ea -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
    3   CoreFoundation                      0x00007fff90a1c5ce ___forwarding___ + 414
    4   CoreFoundation                      0x00007fff90a1c3b8 _CF_forwarding_prep_0 + 232
    5   SimpleJsonParser                    0x0000000100001700 main + 704
    6   libdyld.dylib                       0x00007fff850b57e1 start + 0
    7   ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminate called throwing an exception
(lldb) 

Why property “dateString” of Day class saved as NSDictionary?

  • 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-15T17:26:32+00:00Added an answer on June 15, 2026 at 5:26 pm

    You are adding the dictionary object to array not Day object.

    Change:

    [daysSource addObject:day];
    

    to

    [daysSource addObject:dayObject];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple form interface set up that send username and password information
I'm making a simple Todo application in Cocoa. I have added a class (and
I have a very simple Mac Cocoa app that just has a Web View
I have a simple cocoa application with an editable textfield text1 at the top
I'm trying to design a simple Cocoa application and I would like to have
I have a relatively simple goal: I want to create a Cocoa application which
Hey guys, I have a Cocoa application that sends an NSDictionary over the network
I have a cocoa application that has a view which is clickable. I cannot
I have an application that downloads information from a web service and caches it
I have a simple test application that I am having problems with. the UI

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.