Objective C - 不知道 class 选择方法

Objective C - No know class method for selection

我正在尝试实现一个数据库系统,其中一个实体在其 DataClass.m 中包含一些方法,但我无法在我的 ViewController.m

中调用它们

在上面的代码中,我尝试调用 savePersona,但构建显示

No known class method for selector 'savePersona:etaLabel:indirizzoLabel:contextLabel:'

ViewController.m

#import "ViewController.h"
#import "Giovanni+CoreDataClass.h"
#import "AppDelegate.h"


@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

/*
 * Event after clicking button Save.
 */
- (IBAction)btnSave:(id)sender {
    NSString *nome = _insertName.text;
    NSString *eta = _insertAge.text;
    NSString *indirizzo = _insertIndirizzo.text;

    // Check for all inputs
    if ([nome isEqualToString:@""] || [eta isEqualToString:@""] || [eta intValue] <= 0 || [indirizzo isEqualToString:@""] ) {
        _resultText.text = @"All fields are required";
        return;
    }


    [Giovanni savePersona:nome etaLabel:[eta intValue] indirizzoLabel:indirizzo contextLabel:[((AppDelegate *)[[UIApplication sharedApplication] delegate]) managedObjectContext]];
}

乔瓦尼+CoreDataClass.h

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@interface Giovanni : NSManagedObject

+(void)savePersona: (NSString*)nome etaLabel:(int16_t)eta indirizzoLabel:(NSString*)indirizzo contextLabel:(NSManagedObjectContext *)context;

@end

#import "Giovanni+CoreDataProperties.h"

Giovanni+CoreDataClass.m

#import "Giovanni+CoreDataClass.h"

@implementation Giovanni

+(void)savePersona: (NSString*)nome etaLabel:(int16_t)eta indirizzoLabel:(NSString*)indirizzo contextLabel:(NSManagedObjectContext *)context {
    Giovanni *p1 = [[Giovanni alloc] initWithContext:context];
    p1.nome = nome;
    p1.eta = eta;
    p1.indirizzo = indirizzo;
}

在构建阶段我有 Giovanni+CoreDataClass.m 和 Giovanni+CoreDataProperties.m。 在 Copy Bundle Recources 中,我有 DatabaseExample.xcdatamodeld(DatabaseExample 是项目的名称)

您似乎已将 class 文件命名为 category,但您并未使用 categories

尝试将 Giovanni+CoreDataClass 重命名为 GiovanniCoreData

我已经通过重新创建项目解决了我的问题。

一切都没有改变,但当我点击编辑器 -> 创建 NSManagedObject 子类时 XCode 在自动创建我的实体时遇到了一些问题...

不知道是不是最新版本的bug,现在项目运行正常