no known class method for selector confusion
10,719
You are calling a class method from another in the right way except the method signature is not the same as it is declared;
bool asd =[CoreDataHelper insertAllObjectsForEntity:@"Contact"
andContext:managedObjectContext
initCoreData:jsonDict];
The declaration of +insertAllObjectsForEntity:andContext: does not have the last one in the calling code above
+(BOOL)insertAllObjectsForEntity:(NSString*)entityName
andContext:(NSManagedObjectContext *)managedObjectContext;
Related videos on Youtube
Author by
tugce
Updated on September 15, 2022Comments
-
tugce over 1 year
I know this is a newbie question, but I am all confused. How should I call class method from another class, or shouldn't I?
Here is my
ClassA
andCoreDataHelper
:#import <Foundation/Foundation.h> @interface ClassA : NSObject { } @property (nonatomic, retain) NSString * sessionId; @property (nonatomic, retain) NSString * token; @property (nonatomic, retain) NSString * userid; + (void) pullOfflineDataWithContext:(NSManagedObjectContext *)managedObjectContext ; @end #import "ClassA.h" #import "CoreDataHelper.h" @implementation ClassA + (void) pullOfflineDataWithContext:(NSManagedObjectContext *)managedObjectContext { // get Contacts, Accounts, Meetings into Core Data bool asd =[CoreDataHelper insertAllObjectsForEntity:@"Contact" andContext:managedObjectContext initCoreData:jsonDict]; } @end #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @interface CoreDataHelper : NSObject //For inserting objects +(BOOL)insertAllObjectsForEntity:(NSString*)entityName andContext:(NSManagedObjectContext *)managedObjectContext; @end
-
tugce over 11 yearsbut compiler should not warn me as "no known class method for selector"
-
Simon over 11 years@tugce Well, actually compiler is right according to Objective-C rule: +insertAllObjectsForEntity:andContext:initCoreData: makes one complete method signature that has quite similar semantic of 'symbol' in C.