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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T06:13:15+00:00 2026-06-19T06:13:15+00:00

I have this object: @interface Song : NSManagedObject @property (nonatomic, strong) NSString *songName; @property

  • 0

I have this object:

@interface Song : NSManagedObject

@property (nonatomic, strong) NSString *songName;
@property (nonatomic) int32_t achievedPoints;

When I set the properties like this

Song *song1 = [[SongStore sharedStore] createSong]; 
song1.songName = @"Song 1";
song1.achievedPoints = 0;

everything works, however once I try to set the achievedPoints variable to something else than 0 I get an EXC_BAD_ACCESS.

This is what the createSong method does:

- (Song *)createSong {
    double order;
    if ([allSongs count] == 0) {
        order = 1.0;
    } else {
        order = [[allSongs lastObject] orderingValue] + 1.0;
    }

    Song *p = [NSEntityDescription insertNewObjectForEntityForName:@"Song" inManagedObjectContext:context];

    [p setOrderingValue:order];
    [allSongs addObject:p];
    return p;
}

I have no idea why getting the value and setting it to 0 works but anything else than zero crashes the program. Any help is highly appreciated.

  • 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-19T06:13:15+00:00Added an answer on June 19, 2026 at 6:13 am

    This has happened to me once before. I don’t know exactly which settings gets messed up, but there is a setting in your managed object model, I think, that controls whether or not the class should use primitive values (int, float, etc) or object values (NSNumber *, etc) to set its values. If this gets messed up, and you think you are setting a primitive when you are actually setting an object the following will happen:

    //song1.achievedPoints = 0;
    song1.achievedPoints = (NSNumber *)0x00000000; 
    //This is OK because it is the same as nil
    
    //song1.achievedPoints = 1;
    song1.achievedPoints = (NSNumber *)0x00000001; //You can see why this is bad!
    

    My solution was to regenerate the class via the Create NSManagedObject Subclass template, making sure that Use Scalar Values for Primitives was checked.

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

Sidebar

Related Questions

i have a Person classs @interface Person : NSObject @property (nonatomic, strong) NSString *
I have this interface: public interface IValidationCRUD { public ICRUDValidation IsValid(object obj); private void
We have lot of object with this kind of design : Interface and several
I have this interface Interface IProDataSource Delegate Sub DstartingHandler(ByVal sender As Object, ByVal e
I have this class: @interface RSSEntry : NSObject{ NSString *blogTitle; NSString *articleTitle; NSString *articleUrl;
So I have this class: @interface AmountViewController : UITableViewController <UITableViewDelegate, UITextFieldDelegate>{ NSManagedObjectContext *managedObjectContext; NSManagedObject
I have this interface for using AutoMapper: public interface IMapper { object Map(object source,
I have this object: stdClass Object ( [daily_inventoryID] => 1 [inventory_timestamp] => 2012-06-08 14:35:42
I have this object I'm loading with THREE.objLoader and then create a mesh with
I have this object: class a { public string Application; public DateTime From, To;

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.