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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:37:35+00:00 2026-06-14T04:37:35+00:00

I am using core data first time in my application for my problem I

  • 0

I am using core data first time in my application for my problem I have done google a lot but I didn’t find specific solution.

I have Entity:SubCategory

Attributes:mainCategoryId,subCategoryName.

Now I want to fetch the data like

Select subCategoryName from SubCategory where mainCategoryId=1;

The code which I have implemented is as follows:

 NSFetchRequest *request = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"SubCategory" inManagedObjectContext:managedObjectContext];

    [request setEntity:entity];

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SubCategoryName == %@",@"Triangular1"];
    [request setPredicate:predicate];

    NSError *error;
    arrSubCategory = [managedObjectContext executeFetchRequest:request error:&error];

How can I fetch similar kind of data in coredata

share your ideas

thanx 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-14T04:37:36+00:00Added an answer on June 14, 2026 at 4:37 am

    From your question what you need is,

    [NSPredicate predicateWithFormat:@"mainCategoryId = %@",@"1"];
    

    So your code will look like,

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription
        entityForName:@"SubCategory" inManagedObjectContext:context];
    [fetchRequest setEntity:entity];
    
    NSPredicate *predicate =[NSPredicate predicateWithFormat:@"mainCategoryId = %@",@"1"];
    [request setPredicate:predicate];
    
    NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
    for (NSManagedObject *info in fetchedObjects) {
        NSLog(@"subCategoryName: %@", [info valueForKey:@"subCategoryName"]);
    }
    

    The above is just a sample code. Actual implementation could be different based on your requirement.

    A tutorial on coredata is here. Check that out as well.

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

Sidebar

Related Questions

I'm trying to make my first application using Objective C + Core Data, but
i am using SBJSON and Core Data for the first time. I have a
i am using Core Data for the first time in my iOS application. I
i am stuck with my first GCD and first core-data using application =) two
I am using Core Data for the first time and was just curious if
I'm using core data on an iPhone application. I have multiple persisntent stores that
I am writing my first comprehensive app using Core Data, and I want to
I've been creating an iPhone App using Core Data. First of all, does it
i am using core data in my application. i am getting this error when
I am using core data to store some details. But when I run my

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.