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

  • Home
  • SEARCH
  • 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 5991681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:25:20+00:00 2026-05-22T23:25:20+00:00

I am looking for a basic pattern where I can move some shared code.

  • 0

I am looking for a basic pattern where I can move some shared code. I have an NSManagedObject PurchaseOrder which is stored in Core Data. This can be edited and changed in several different views. Most of the time it is always the same type of change, PurchaseOrder is updated with data from another NSManagedObject Client.

I am wanting to move this type of code to a single place so I can call something like:

-(void) updatePurchaseOrder: (PurchasOrder *) aPurchaseOrder withClient:(Client *) aClient withManagedObjectContext: (NSManagedObjectContext *) aManagedObjectContext {
 // update code goes here
}

Is this a bad idea or a recipe for disaster? I do have a shared instance class I am using already (small bit of bit below):

static SharedFunctions* singletonInstance = nil;

-(id)init
{
    if ((self = [super init]))
    {

    }
    return self;
}


+(SharedFunctions*)sharedInstance
{
    @synchronized(self) {
        if (singletonInstance == nil) 
        {
            singletonInstance =  [[SharedFunctions alloc] init]; 
        }
    }
    return singletonInstance;
}

Which I call function like this:

[[[SharedFunctions] sharedInstance] myMethod];

This has been working well for me. Thoughts?

  • 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-22T23:25:21+00:00Added an answer on May 22, 2026 at 11:25 pm

    Where is your updatePurchaseOrder method defined? In this situation, I would create a custom PurchaseOrder subclass of the NSManagedObject and implement an updateWithClient method.

     @interface PurchaseOrder : NSManagedObject {
     }
    
    -(void)updateWithClient:(Client *)client;
    
    @end
    

    So you can simply call [aPurchaseOrder updateWithClient:aClient]; where you need to. Seems more OO, unless I’m missing something?

    If you’ve not made a custom subclass for PurchaseOrder, you could do the same thing in a category of NSManagedObject.

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

Sidebar

Related Questions

I'm looking for an internal representation format for text , which would support basic
Tried looking around for a regex pattern for a full name and just can't
I have a few basic questions about the Dispose Pattern in C#. In the
I'm working on a basic eCommerce site and I am looking for some help
So I am really stumped because I have basic ideas but I am looking
Well, I know it may sounds basic, but I have literally been looking everywhere
I am looking for basic examples/tutorials on: How to write/compile libraries in C++ (
I'm looking for the basic loop like: for (int i = 0; i <
I'm looking at building basic CMS functionality into our web product and am researching
I'm looking for a basic software for statistical analysis. Most important is simple and

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.