I tried to search for an answer about this (simple) question but nothing seems to work well, even books are not so specific (atleast the books I've read), or probably I'm simply missing something important, since I'm a little bit confused I've decided to try here.
Here's the question:
Say that I have a ClassA which contains one or many instance variables. Then I have a ClassB which contains an Instance Method that modify ClassA variable (is this possible right?) the classes have NOT inheritance from each other, both inherits from NSObject
Then I want to call the method of the ClassB over the ClassA object on the UIViewController. I believe I need a reference between classes but i'm not sure on how to set them to make them works. Imagine I have a Paper which contains writes or numbers (in this case numbers) and a class erase to modify it's variable and erase numbers (for example by subtracting).
here's some code:
Paper.h
@interface Paper : NSObject
@property (nonatomic) int numbers;
@end
Paper.m
#import "Paper.h"
@implementation Paper
@synthesize numbers;
@end
and Eraser.h
@interface Eraser : NSObject
-(void)eraseMethod;
@end
Eraser.m
#import "Eraser.h"
@implementation Eraser
-(void)eraseMethod {
//here I want to make a subtraction of the ivar declared in Paper
}
@end
and finally I'm trying to call it on the UIViewController like so
[paperObject eraseMethod];
I tried by declaring @class in each files as I've read somewhere but this won't help in any way... I hope this is clear as question