iosobjective-cdesign-patterns

How do I hide the public API methods of my extending class?


I have written an DataAdapter library that has dependency(tightly coupled) with a core-data library (coredata library helps to store, manage data in the database) and hence I create API's in DataAdapter class extending the core data class to have quick access to all the API's of core data class.

However, as I have extended the core data class in my DataAdapter class, all the API's in core data class is visible to the developer through DataAdapter class (which I don't want to happen, basically wanting him to use adapter API methods only.)

E.g.: Core data has an API as:

  • (CoreDataResponse *) getAllManagedObjectsOfEntity:(CoreDataRequest *)request;

DataAdapter has an API as:

-(DBResponse *)getAllStoredRecordsFromDB;

The exact issue is, Xcode autosuggestion for adapter methods shows up core data API'S as well as below - but I want my developer using the data adapter to access only the API methods of DataAdapter, How can I achieve it?

enter image description here

Update -1: This is my Adapter header class extended with coredata

#import "CoreDataManager.h"

@interface DataAdapter : CoreDataManager
-(DBResponse *)getAllStoredRecordsFromDB;
@end

Solution

  • In //DataAdapter.m

    #import <CoreData/CoreData.h>
    
    @interface DataAdapter()
    @property (strong, nonatomic) CoreDataAdapter *adapter;
    @end
    
    @implementation DataAdapter
    
    @end