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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:50:39+00:00 2026-06-15T23:50:39+00:00

I am reading jason data from my json file, and i am successful in

  • 0

I am reading jason data from my json file, and i am successful in printing the NSarray type arraytsik, now when i try to loop through the arraytsik using enumerateObjectsUsingBlock it’s giving me outup or array with error

 2012-12-17 16:59:04.711 tsikzoeMig[6416:303] here i am printing the array {
    tsik =     (
                {
            author = 2;
            authorName = fgfg;
            dateSubmitted = "2012-08-19 00:00:00";
            dictionaryType = 1;
            id = 1;
            word = fgdf;
            wordDef = fdgdfg;
        },
                {
            author = 2;
            authorName = "\U0f51\U0f74\U0f44\U0f0b\U0f51\U0f40\U0f62\U0f0b\U0f5a\U0f72\U0f42\U0f0b\U0f58\U0f5b\U0f7c\U0f51\U0f0d";
            dateSubmitted = "2012-08-19 00:00:00";
            dictionaryType = 1;
            id = 2;
            word = "\U0f21\U0f20\U0f24\U0f20\U0f56\U0f66\U0f7c\U0f0d";
            wordDef = "\U0f56\U0f66\U0f7c\U0f0b\U0f56\U0f66\U0f7c\U0f0b\U0f5e\U0f7a\U0f66\U0f0b\U0f54\U0f60\U0f72\U0f0b\U0f66\U0f92\U0fb2\U0f60\U0f72\U0f0b\U0f41\U0fb1\U0f51\U0f0b\U0f54\U0f62\U0f0b\U0f42\U0fb1\U0f72\U0f0b\U0f58\U0f72\U0f44\U0f0c\U0f0d";
        }
    );
}
2012-12-17 16:59:04.712 tsikzoeMig[6416:303] -[__NSCFDictionary enumerateObjectsUsingBlock:]: unrecognized selector sent to instance

0x102114700
2012-12-17 16:59:04.713 tsikzoeMig[6416:303] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason:
‘-[__NSCFDictionary enumerateObjectsUsingBlock:]: unrecognized
selector sent to instance 0x102114700’
*
First throw call stack:
(
0 CoreFoundation 0x00007fff8a1190a6 exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8a2963f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8a1af6ea -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
3 CoreFoundation 0x00007fff8a1075ce __forwarding
+ 414
4 CoreFoundation 0x00007fff8a1073b8 _CF_forwarding_prep_0 + 232
5 tsikzoeMig 0x0000000100001cd3 main + 851
6 libdyld.dylib 0x00007fff8acd97e1 start + 0
7 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminate called throwing an exception
(lldb)

my main.m code is here

//  main.m

#import "TsikzoeE.h"
static NSManagedObjectModel *managedObjectModel()
{
    static NSManagedObjectModel *model = nil;
    if (model != nil) {
        return model;
    }

    NSString *path = @"tsikzoe";
    NSURL *modelURL = [NSURL fileURLWithPath:[path stringByAppendingPathExtension:@"momd"]];
    model = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];

    return model;
}

static NSManagedObjectContext *managedObjectContext()
{
    static NSManagedObjectContext *context = nil;
    if (context != nil) {
        return context;
    }

    @autoreleasepool {
        context = [[NSManagedObjectContext alloc] init];

        NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:managedObjectModel()];
        [context setPersistentStoreCoordinator:coordinator];

        NSString *STORE_TYPE = NSSQLiteStoreType;

        NSString *path = [[NSProcessInfo processInfo] arguments][0];
        path = [path stringByDeletingPathExtension];
        NSURL *url = [NSURL fileURLWithPath:[path stringByAppendingPathExtension:@"sqlite"]];

        NSError *error;
        NSPersistentStore *newStore = [coordinator addPersistentStoreWithType:STORE_TYPE configuration:nil URL:url options:nil error:&error];

        if (newStore == nil) {
            NSLog(@"Store Configuration Failure %@", ([error localizedDescription] != nil) ? [error localizedDescription] : @"Unknown Error");
        }
    }
    return context;
}

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

    @autoreleasepool {
        // Create the managed object context
        NSManagedObjectContext *context = managedObjectContext();

        // Custom code here...
        // Save the managed object context
        NSError *error = nil;
        if (![context save:&error]) {
            NSLog(@"Error while saving %@", ([error localizedDescription] != nil) ? [error localizedDescription] : @"Unknown Error");
            exit(1);
        }
        NSError* err = nil;

        NSString* dataPath = [[NSBundle mainBundle] pathForResource:@"tsikzoe" ofType:@"json"];
        NSArray* arraytsik = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:dataPath]options:kNilOptions error:&err];

        // array outputing here to check

        NSLog(@"here i am printing the array %@",arraytsik);


        [arraytsik enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {


           TsikzoeE *tsikz = [NSEntityDescription insertNewObjectForEntityForName:@"TsikzoeE"inManagedObjectContext:context];
            tsikz.id = [obj objectForKey:@"id"];
            tsikz.dictionaryType=[obj objectForKey:@"dictionaryType"];
            tsikz.word=[obj objectAtIndex:3];
            tsikz.wordDef=[obj objectForKey:@"wordDef"];
            tsikz.author=[obj objectForKey:@"author"];
            tsikz.authorName=[obj objectForKey:@"authorName"];
            NSError *error;
            if (![context save:&error]) {
                NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]);
            }
        }];

        NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
        NSEntityDescription *entity = [NSEntityDescription entityForName:@"TsikzoeE"
                                                  inManagedObjectContext:context];
        [fetchRequest setEntity:entity];
        NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
        for (TsikzoeE *tsikz in fetchedObjects) {
            NSLog(@"word: %@", tsikz.word);

            NSLog(@"wordDef: %@", tsikz.wordDef);
        }

    }
    return 0;
}

my json content is

{"tsik":[{"id":1,"dictionaryType":1,"word":"fgdf","wordDef":"fdgdfg","dateSubmitted":"2012-08-19 00:00:00","author":2,"authorName":"fgfg"},{"id":2,"dictionaryType":1,"word":"༡༠༤༠བསོ།","wordDef":"བསོ་བསོ་ཞེས་པའི་སྒྲའི་ཁྱད་པར་གྱི་མིང༌།","dateSubmitted":"2012-08-19 00:00:00","author":2,"authorName":"དུང་དཀར་ཚིག་མཛོད།"}]}

my TsikzoeE.h code

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>


@interface TsikzoeE : NSManagedObject

@property (nonatomic, retain) NSNumber * author;
@property (nonatomic, retain) NSString * authorName;
@property (nonatomic, retain) NSNumber * dictionaryType;
@property (nonatomic, retain) NSNumber * id;
@property (nonatomic, retain) NSString * word;
@property (nonatomic, retain) NSString * wordDef;


@end

tsikzoeE.m code

  //
//  TsikzoeE.m


#import "TsikzoeE.h"


@implementation TsikzoeE

@dynamic author;
@dynamic authorName;
@dynamic dictionaryType;
@dynamic id;
@dynamic word;
@dynamic wordDef;

@end
  • 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-15T23:50:40+00:00Added an answer on June 15, 2026 at 11:50 pm

    The JSON data contain a dictionary (with one key “tsik”) and not an array.

    The following should work better:

    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:dataPath] options:kNilOptions error:&err];
    NSArray *arraytsik = [dict objectForKey:@"tsik"];
    

    There seems also to be a problem inside the enumerateObjectsUsingBlock block: obj is a dictionary here, so

    tsikz.word=[obj objectAtIndex:3];
    

    does not work. Perhaps you meant

    tsikz.word=[obj objectForKey:@"word"];
    

    Remark: You could also consider to save the managed object context after the loop has completed instead of saving it for each item added.

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

Sidebar

Related Questions

I try reading a JSON file from R using rjson but keep getting errors.
I am reading data from a json file and the titles of the key/value
I am reading contents from JSON file and adding to div with unique IDs.
I'm reading JSON data from a PHP Service and everytime the version of that
I was doing Json parsing. As of now, I was reading it from a
I'm having trouble reading the JSON data from a venues search. Here is my
I'm reading JSON data with PHP and that data contains empty objects (like {}
Well I have a problem reading the JSON data in jQuery, which is outputted
I'm exporting some data from a kml file to mysql, there's an xml chunk
I had created a Django view which is returning some data after reading from

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.