My method may not respond and I can’t get why
in ClassA.h:
@interface ClassA : NSObject {
NSString *inStr;
NSInteger *peak;
}
@property (retain,nonatomic) NSString *inStr;
@end
in ClassA.m
NSLog(@"%d peaks",peak);
peak++;
inStr = [NSString stringWithFormat:@"Peaks : %d",peak ];
[ClassB setUpdateLabel:inStr];
in ClassB.h
@interface ClassB : NSObject {
IBOutlet UILabel *peaksLabel;
NSString *tempStr;
}
@property (nonatomic, retain) UILabel *peaksLabel;
- (void) setUpdateLabel:(NSString*)inStr;
@end
in ClassB.m
#import ClassB.h
@implementation classB;
-(void) setUpdateLabel:(NSString*)inStr{
peaksLabel.text=inStr;
}
Anyone can help me ?
You are declaring
- (void) setUpdateLabel:(NSString*)inStr;as a instance method, however you are using it as a class method.‘-‘ indicates instance methods
‘+’ indicates class methods
If you want this to work you either change the declaration to
+ (void) setUpdateLabel:(NSString*)inStr;or you make an object of the Class B like this:and remember to release it.