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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:47:02+00:00 2026-06-17T07:47:02+00:00

Simple question. Could anyone tell me what’s wrong with this piece of code? +

  • 0

Simple question. Could anyone tell me what’s wrong with this piece of code?

+ (NSManagedObject*) managedObjectWithServerId:(NSInteger)serverId inManagedObjectContext:(NSManagedObjectContext*)context{

    //Execute request and get all the results
    NSError * error = nil;
    NSFetchRequest * request = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass(self)];
    request.predicate = [NSPredicate predicateWithFormat:@"serverId == %@" argumentArray:[NSArray arrayWithObject:[NSNumber numberWithInteger:serverId]]];
    NSArray * results = [context executeFetchRequest:request error:&error];
}

The results array is always an NSArray with 0 objects, no errors are given, nothing. Just a 0-count array.
And it’s not possible to return always 0 elements, I am exploring the Core Data database with a SQLite explorer, and there are elements with the serverId I am requesting, so there should be at least 1.

Am I doing the predicate wrong?

The above code is implemented in an NSManagedObject category, and called as shown:

 [User managedObjectWithServerId:whatev inManagedObjectContext:context];

Where User is an entity in my model and subclass of NSManagedObject.

  • 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-17T07:47:03+00:00Added an answer on June 17, 2026 at 7:47 am

    Problem fixed, it seems I was always re-creating the Database file because of an unexpected condition. I noticed because all the Primary Keys were always starting from 1.

    CoreData seems to have some issues if you don’t delete the previous UIManagedDocument Database file before creating the new one.

    With the condition fixed, I get no NSPersistentStoreCoordinator crash error, I can see all the SQL methods with debugging and my fetches, of course, works correctly.

    Thanks to all the people who tried helping, and sorry for wasting your time 🙂

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

Sidebar

Related Questions

This could be a simple scoping question. The following code in a Python file
I understand that this question could be answered with a simple sentence and that
I am new on this stuff and this could be a simple question, but
this might be a very simple question, but I could not find an answer
Probably this is a simple question, Does anyone know how to hide the default
A really simple question but I could not figure it out... I tried to
I have a rather simple question that I could normally debug myself, but I
Simple question, could'nt find a straight answer. How can I modify the output file
This looked like a very simple question but I couldn't find the answer. How
This is a simple question really (but I couldn't seem to find the answer

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.