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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:29:20+00:00 2026-06-01T06:29:20+00:00

Can someone walk me through how to ‘hide’ the standard core data setters? I

  • 0

Can someone walk me through how to ‘hide’ the standard core data setters?

I know there is not really a way to define ‘Private’ methods in Objective-C, but read about using an extension to achieve a similar result. The problem is, I want to apply this to core data classes. I would like to hide the standard setters created for some attributes, and only call them from inside other, exposed setters.

An example: My core data object has a BOOL ‘collected’ and a date ‘dateCollected’. I have figured out how to add setDateCollected to setCollected, but now I would like to ‘hide’ set collected so that it can’t be called directly so easily (when I might forget to also set dateCollected manually).

To clarify, the part that is tripping me up is the ‘@dynamic’ calls – I don;t know where these should live.

EDIT – I guess I missed a part. I can move the @property declaration into the implementation file just fine. But I want the setter to be hidden, and the getter to remain public. I guess I need to replace the @property, but I don’t know how to do this for a core data object.

  • 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-01T06:29:22+00:00Added an answer on June 1, 2026 at 6:29 am

    You define private methods in the implementation file. If a method is not shown in the header file, then by definition, it is private. To clarify, the following is how you define public properties and methods.

    @interface MyAppViewController : UIViewController
    
    @property (strong, nonatomic) NSString *myPublicStringObject;
    
    - (NSString *) myPublicMethodTakingInputString:(NSString *) input;
    
    @end
    

    In the implementation file, you can define private properties and methods as follows.

    #import "MyAppViewController.h"
    
    // Declare private properties and methods inside the following interface extension
    @interface MyAppViewController ()
    
    @property (strong, nonatomic) NSNumber     *myPrivateNumber;
    @property (strong, nonatomic) NSString     *myPrivateStringObject;
    
    - (void) myPrivateMethod1;
    - (NSString *) myPrivateMethod2WithIntegerInput:(NSInteger) input;
    
    @end
    
    
    @implementation MyAppViewController
    
    @synthesize myPublicStringObject;
    @synthesize myPrivateNumber;
    @synthesize myPrivateStringObject;
    
    // Implement all methods declared in header and private interfaces here in no particular order
    - (NSString *) myPublicMethodTakingInputString:(NSString *) input
    {
    // code for myPublicMethodTakingInputString
    }
    
    - (void) myPrivateMethod1
    {
    }
    
    - (NSString *) myPrivateMethod2WithIntegerInput:(NSInteger) input
    {
    }
    
    
    // Implement any other private method not declared
    - (NSString *) myUndeclaredPrivateMethod1:(NSString *) input
    {
    // code for myUndeclaredPrivateMethod1
    }
    
    
    - (id) myUndeclaredPrivateMethod2
    {
    // code for myUndeclaredPrivateMethod2
    }
    

    … etc.

    This description is for iOS 5 of course. The syntax for iOS3 & 4 is similar except that the private instant variables (iVars) appear in the header file–which could be very confusing for newbies. iOS 5 cleaned this up, by not requiring instant variables to appear anywhere.

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

Sidebar

Related Questions

Can someone point me to a [relatively] simple walk-through on how to properly configure
Can someone please walk me through mathematical part of the solution of the following
Can someone walk me through it? I don't understand what parameters are passed and
QUESTION Can someone help walk me through the general approach to solving this problem?
http://jung.sourceforge.net/ Can someone walk through the steps carefully for me? I have been trying
Can someone walk me through the best way to do this? I want to
I'm trying to walk someone through adding CorePlot to their iPhone app. I have
I dont really understand what the last while loop is doing, can someone explain
Can someone show me how to implement a recursive lambda expression to traverse a
Can someone explain the mechanics of a jump table and why is would be

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.