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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:53:43+00:00 2026-06-01T01:53:43+00:00

I have some NSManagedObject classes created for use with CoreData I need to add

  • 0

I have some NSManagedObject classes created for use with CoreData I need to add some additional properties for formatting I am doing using GRMustache templates.

Here is an example property:

-(NSString *) PriceFormatted {
    NSNumberFormatter *nfm = [[[NSNumberFormatter alloc] init] autorelease];
    [nfm setNumberStyle:NSNumberFormatterCurrencyStyle];
    [nfm setCurrencyCode:[Helpers GetCurrencyCode]];
    [nfm setNegativeFormat:@"-¤#,##0.00"];
    [nfm setMaximumFractionDigits:2];

    return [nfm stringFromNumber:self.Price];
}

I currently have this in my generated NSManagedObject class but this will cause issues if I need to regenerate a new NSManagedObject class.

Can I define these properties in a secondary set of classes – similar to partials in C#?

  • 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-01T01:53:45+00:00Added an answer on June 1, 2026 at 1:53 am

    Probably the easiest way is to add a category to your generated managed object.

    Here is Apple’s documentation on it, it is pretty easy.

    To quote:

    You can add methods to a class by declaring them in an interface file
    under a category name and defining them in an implementation file
    under the same name. The category name indicates that the methods are
    additions to a class declared elsewhere, not a new class. You cannot,
    however, use a category to add additional instance variables to a
    class.

    The methods the category adds become part of the class type. For
    example, methods added to the NSArray class in a category are included
    as methods the compiler expects an NSArray instance to have in its
    repertoire. Methods added to the NSArray class in a subclass, however,
    are not included in the NSArray type. (This matters only for
    statically typed objects because static typing is the only way the
    compiler can know an object’s class.)

    Category methods can do anything that methods defined in the class
    proper can do. At runtime, there’s no difference. The methods the
    category adds to the class are inherited by all the class’s
    subclasses, just like other methods.

    The declaration of a category interface looks very much like a class
    interface declaration—except the category name is listed within
    parentheses after the class name and the superclass isn’t mentioned.
    Unless its methods don’t access any instance variables of the class,
    the category must import the interface file for the class it extends:

        #import "ClassName.h"   
    
        @interface ClassName ( CategoryName ) 
            // method declarations 
        @end 
    

    Note that a category can’t declare additional
    instance variables for the class; it includes only methods. However,
    all instance variables within the scope of the class are also within
    the scope of the category. That includes all instance variables
    declared by the class, even ones declared @private.

    There’s no limit to the number of categories that you can add to a
    class, but each category name must be different, and each should
    declare and define a different set of methods.

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

Sidebar

Related Questions

I'm using custom classes for my CoreData stack. Class properties are set properly in
I have some classes layed out like this class A { public virtual void
I have some XML data retrieved from a web service that I use to
I'm new to Cocoa and xCode, but not programming though. I have created some
I have one subclass of NSManagedObject like following and stored some instances by NSManagedObjectContext.
I have a subclass of an NSManagedObject, and I'd like to add a couple
So I noticed some strange behavior when using a subclass of a NSManagedObject as
I have a NSManagedObject subclass, created by the XCode model interface. This class has
I have an NSPersistentDocument subclass using NSManagedObject subclasses for my data. When a new
i have some Data in a TableView (loaded from coreData) and now i want

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.