Question: Calling a method from another class. error : No visible @interface ... declares the selector

Question

Calling a method from another class. error : No visible @interface ... declares the selector

Answers 1
Added at 2016-12-26 14:12
Tags
Question

I have two classes DetailViewController and Substitution, I would use the Substitution class methods but I get this error:

No visible @interface "Substitutions" declares the selector "Crypt ::"

DetailViewController.h

#import <UIKit/UIKit.h>

#import "Substitutions.h"

@interface DetailViewController : UIViewController

@property (weak, nonatomic) IBOutlet UITextField *tvC;

- (IBAction)bCrypter:(id)sender;

@property (nonatomic, strong) Substitutions * s;

DetailViewController.m

#import "DetailViewController.h"

@implementation DetailViewController

@synthesize s;
@synthesize tvC;

- (IBAction)bCrypter:(id)sender
{
    s = [[Substitutions alloc]init];
    [s Crypter:tvC.text :1]; <-- No visible @interface "Substitutions" declares the selector "Crypter::" 
    //NSLog(@"%@",tvC.text);   
}

Substitutions.h

@interface Substitutions : NSObject

+ (NSString*)Crypter:(NSString*)msg :(id)cles;

@end

Substitutions.m

#import "Substitutions.h"

@implementation Substitutions


+ (NSString*)Crypter:(NSString*)msg :(id)cles
{
    NSLog(@"%@",msg);
    return @"";
}
Answers
nr: #1 dodano: 2016-12-26 14:12

Because Crypter is class method not instance method so you should call directly with class name not need to create instance for call method.

Ex.

[Substitutions Crypter:tvC.text :1];
Source Show
◀ Wstecz