Possible Duplicate:
Unable to access object of other class
I've been working on a little project just to increase my comprehension of the objective-c syntaxe and functionalities but I'm stuck in my own project and can't find the answer.
First I've got two classes and in my main one I have declare a object of my other class so I can use the functions from my other class. This is how I did it (I just wrote the thing that I thought were necessary:
.h of my main class
import myOtherClass
@interface PkmViewController : UIViewController
@property Pokemon * nomDePokemon;
.m of my main class
import myOtherClass
@synthesize nomDePokemon;
int nbDef = [nomDePokemon calculerUnNombrePourLaDefense];
.h of my other class
@interface Pokemon : NSObject
@property int defencePoints;
-(int)calculerUnNombrePourLaDefense;
.m of my other class
@synthesize defencePoints;
-(int)calculerUnNombrePourLaDefense
{
int nombrerandom = arc4random() % 45;
return nombrerandom;
}
When I put a breakpoint in my main class to see what number is taken from the function, it always gives me 0. And when I put this section in my other class it works but I want to keep it in another class to improve my skills. Someone can explain me how to do it please?