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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:48:32+00:00 2026-06-13T01:48:32+00:00

I have More than 5000 Record to be loaded from Server to my App

  • 0

I have More than 5000 Record to be loaded from Server to my App and Inserted into Database.
While inserting these records after some successful insertion I am getting this kind of error and my app crashes.

database is malformed in iPhone + error disk i/o error

Following are code snippet that could be useful,Here I am getting Records in 5 Categories One by One and Inserting them into Database

    if (tag==1) {
        NSMutableDictionary *catDic=[dic valueForKeyPath:@"GetAllRecords.results.categories.category"];
        [self performSelectorInBackground:@selector(insertDataInCategoryMaster:) withObject:catDic];

        NSMutableDictionary *levelDic=[dic valueForKeyPath:@"GetAllRecords.results.levels.level"];
        [self performSelectorInBackground:@selector(insertDataInLevelMaster:) withObject:levelDic];

        NSMutableDictionary *queDic=[dic valueForKeyPath:@"GetAllRecords.results.questions.question"];

        [self performSelectorInBackground:@selector(insertDataInQueMaster:) withObject:queDic];

        [self getQueCatLevelData:2];
    }
    else if(tag==2){

        NSMutableDictionary *queDic=[dic valueForKeyPath:@"GetAllRecords.results.questions.question"];
        [self performSelectorInBackground:@selector(insertDataInQueMaster:) withObject:queDic];

        [self getQueCatLevelData:3];

    }
    else if(tag==3){

        NSMutableDictionary *queDic=[dic valueForKeyPath:@"GetAllRecords.results.questions.question"];
        [self performSelectorInBackground:@selector(insertDataInQueMaster:) withObject:queDic];

        [self getQueCatLevelData:4];
    }//and so on for 5 also

in each insertDataInQueMaster I am doing following things.

         NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
        for(NSDictionary *queDictionary in dictionary)
        {

            NSString *strQuery = [NSString stringWithFormat:@"insert into QuestionMaster values(%d,'%@','%@',%d,%d,%d,%d,%d,0,'%@')",[[queDictionary valueForKey:@"questionid"]intValue], [queDictionary valueForKey:@"questiontext"],[queDictionary valueForKey:@"answertext"],[[queDictionary valueForKey:@"categoryid"]intValue],[[queDictionary valueForKey:@"levelid"] intValue],[[queDictionary valueForKey:@"status"]intValue],[[queDictionary valueForKey:@"RangeFrom"]intValue],[[queDictionary valueForKey:@"RangeTo"]intValue],[queDictionary valueForKey:@"Fact"]];

            [NSNumber requestWithSynchronousExcuteQuery:strQuery withReturnningError:&error];

            if(error)
            {
                NSLog(@"error description:%@",[[error userInfo] description]);
                [[NSUserDefaults standardUserDefaults]setBool:NO forKey:@"FirstTime"];
            }

        }

        count++;
        [[NSUserDefaults standardUserDefaults]setInteger:count forKey:@"CheckCount"];
        [[NSUserDefaults standardUserDefaults]synchronize];
        [pool drain];

I am doing These all things while App is Loading in AppDelegate.m , that too in Background
The Error Comes After successfully inserting few records in Database so I think there is no problem with Database opening and Inserting.

I hope I am clear,
Please comment if any confusion.
Waiting for reply.
Thanks in advance.

  • 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-13T01:48:37+00:00Added an answer on June 13, 2026 at 1:48 am

    hurray, I got the Simple Solution to this

    I just Placed

      @synchronized(self)
      {
          //My Whole Code  for Background methods goes here
      }
    

    and that’s it, it solved my error and crash too.

    The @synchronized()directive locks a section of code for use by a single thread. Other threads are blocked until the thread exits the protected code—that is, when execution continues past the last statement in the @synchronized() block.

    The @synchronized() directive takes as its only argument any Objective-C object, including self.

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

Sidebar

Related Questions

I have more than 5000 image links and I need to find a way
I have more than 100 million unique strings (VARCHAR(100) UNIQUE in MySQL database). Now
Where I have more than one table in my database for use with (similar,
I have more than 400 000 id's in NOT IN statement. Whether it will
I have more than one Event Listener that calls a specific function, and I
I have more than 3000 members on a site built using wordpress. I am
I have more than 30 images and and i am getting them in a
How can one have more than a Wizard control on the same page without
I would like to have more than one button. I tried to copy code
Can an if statement have more than one then statements? # this works a

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.