Error “No known class method for selector 'Hello:'” in custom-made framework

前端 未结 2 2016
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 04:13

I am making a framework for a company and I have completed all the code. I\'m now trying to package it into a framework. As a test I made a method with this name: -(v

相关标签:
2条回答
  • 2020-12-10 04:38

    please refer to : https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html

    to answer your question, change

    @interface Hello : NSObject
    -(void)Hello:(NSString *)world;
    @end 
    

    to

    @interface CompanyMobile : NSObject{
    }
    +(void)Hello:(NSString *)world;
    @end
    

    and call the method [CompanyMobile Hello:@"world"];

    0 讨论(0)
  • 2020-12-10 04:52

    You defined Hello: as an instance method, but you're sending Hello: to the class. To define a class method, you write + (void)Hello: rather than - (void)Hello:.

    0 讨论(0)
提交回复
热议问题