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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:05:31+00:00 2026-05-14T23:05:31+00:00

My entity has a property (sortOrder) that is of the type Decimal(NSDecimalNumber) but when

  • 0

My entity has a property (sortOrder) that is of the type Decimal(NSDecimalNumber) but when I execute a fetch request using that property as a key, I get back results in a seemingly random order. If I output the value of the property I get really strange values until I get it’s intValue.

Example: The first run produces this result. The first value is the raw value of the property. The second is the intValue, the actual value of the property when I created the object – or at least I thought.

85438160 10

74691424 20

Second run…

85333744 10

85339168 20

Third…

85263696 20

85269568 10

What the hell?

Fetch Request:

NSMutableArray *cats = [[NSMutableArray alloc] initWithArray:[CoreDataHelper searchObjectsInContext:@"RestaurantMenuCategory":nil:@"sortOrder":YES:NO:nil]];

Here is the searchObjectsInContext method from my CoreDataHelperClass:

+(NSMutableArray *) searchObjectsInContext: (NSString*)entityName : (NSPredicate *)predicate : (NSString*)sortKey : (BOOL)sortAscending : (BOOL)distinct : (NSString*)distinctProperty
{
    RestaurantController *ctrl = [RestaurantController sharedRestaurantController];

    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:ctrl.managedObjectContext];
    [request setEntity:entity];

    if(distinct==YES){
        [request setReturnsDistinctResults:YES];
    }

    if(distinctProperty!= nil){
        [request setPropertiesToFetch :[NSArray arrayWithObjects:distinctProperty,nil]];
    }

    if(predicate != nil){
        [request setPredicate:predicate];
    }

    if(sortKey != nil){
        NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:sortKey ascending:sortAscending];
        NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
       [request setSortDescriptors:sortDescriptors];
       [sortDescriptors release];
       [sortDescriptor release];
   }

   NSError *error;

   NSMutableArray *mutableFetchResults = [[[ctrl.managedObjectContext executeFetchRequest:request error:&error] mutableCopy] autorelease];

   [request release];

   return mutableFetchResults;
}
  • 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-05-14T23:05:32+00:00Added an answer on May 14, 2026 at 11:05 pm

    You cannot use a %d format to print out an NSDecimalNumber.

    NSDecimalNumber is an Objective-C object; %d is for printing “int”s. If you use the %d format string, it will probably print something non-useful like the address of the object; use “%@” instead.

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

Sidebar

Related Questions

One of my entity objects (EF4) has a property that is a decimal. The
I have an entity which has a property that does not get its value
When I map an entity that has a property of type System.Type, I know
So there is an entity that has an enum property and a wcf service
My doctrine entity has a datetime property called updated . This should get the
Let's say you've an entity that has a property typed as ICollection<string> and I
I have a User entity that has a IList property. The mapping for this
I have an entity that has an items property that is an array of
I'm using CoreData and my entity has a boolean property called isReward. I'm trying
I have an entity that has a string property called Tags. I would like

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.