How do I Call a method from other Class
Posted
by balexandre
on Stack Overflow
See other posts from Stack Overflow
or by balexandre
Published on 2010-04-05T07:33:28Z
Indexed on
2010/04/05
7:43 UTC
Read the original article
Hit count: 388
objective-c
|call
Hi guys,
I'm having some trouble figuring out to call methods that I have in other classes
#import "myNewClass.h"
#import "MainViewController.h"
@implementation MainViewController
@synthesize txtUsername;
@synthesize txtPassword;
@synthesize lblUserMessage;
- (IBAction)calculateSecret {
NSString *usec = [self calculateSecretForUser:txtUsername.text
withPassword:txtPassword.text];
[lblUserMessage setText:usec];
[usec release];
}
...
myNewClass.h
#import <Foundation/Foundation.h>
@interface myNewClass : NSObject {
}
- (NSString*)CalculateSecretForUser:(NSString *)user withPassword:(NSString *)pwd;
@end
myNewClass.m
#import "myNewClass.h"
@implementation myNewClass
- (NSString*)CalculateSecretForUser:(NSString *)user withPassword:(NSString *)pwd
{
NSString *a = [[NSString alloc] initWithFormat:@"%@ -> %@", user, pwd];
return a;
}
@end
the method CalculateSecretForUser always says
'MainViewController' may not respond to '-calculateSecretForUser:withPassword:'
what am I doing wrong here?
© Stack Overflow or respective owner