在定制框架中出现错误“选择器\'Hello:\'的未知类方法”

|| 我正在为公司创建框架,并且已经完成了所有代码。我现在正尝试将其打包到框架中。作为测试,我制作了一个名称为
-(void)Hello:(NSString *)worldText;
的方法 当我尝试使用代码
[CompanyMobile Hello:@\"World\"];
在带有框架的应用程序中调用它时,出现编译器错误,提示:   没有已知的选择器\'Hello:\'类方法 我的框架中的.m如下:
#import \"Hello.h\"

@implementation Hello

- (id)init
{
    self = [super init];
    if (self) {
        // Initialization code here.
    }

    return self;
}

-(void)Hello:(NSString *)world {

}

@end
我的框架中的.h如下:
#import <Foundation/Foundation.h>

@interface Hello : NSObject
-(void)Hello:(NSString *)world;
@end
我的应用程序中的.h
//
//  FMWK_TESTViewController.h
//  FMWK TEST
//
//  Created by Sam on 6/15/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <companyMobile/Hello.h>
@interface FMWK_TESTViewController : UIViewController

@end
我的应用程序中的.m
//
//  FMWK_TESTViewController.m
//  FMWK TEST
//
//  Created by Sam Baumgarten on 6/15/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import \"FMWK_TESTViewController.h\"

@implementation FMWK_TESTViewController

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren\'t in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [Badgeville Hello:@\"Sam\"];
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return YES;
}

@end
    
已邀请:
        您将
Hello:
定义为实例方法,但您正在向该类发送
Hello:
。要定义一个类方法,您写
+ (void)Hello:
而不是
- (void)Hello:
。     
        请参考:https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html 回答你的问题,改变
@interface Hello : NSObject
-(void)Hello:(NSString *)world;
@end 
@interface CompanyMobile : NSObject{
}
+(void)Hello:(NSString *)world;
@end
并调用方法
[CompanyMobile Hello:@\"world\"];
    

要回复问题请先登录注册