title: Objective C - Get a class to return a value
body: <p>I rarely ask questions, but this one is frustrating me as I can not find an answer anywhere!</p>
  
  <p>I just need to call the function in GameChallenges.m and return the value to the view controller. GameChallenges.m will be called by different view controllers, thats why its separate. Please help!</p>
  
  <p>I have a separate class file called GameChallenges.</p>
  
  <p>This has a function/method in it:
  in the .h</p>
  
  <pre><code>@class StatsViewController;
  
  @interface GameChallenges : NSObject {
  
  
      StatsViewController* statsController;
      NSString* challengeTitle;
  }
  
  @property (nonatomic, retain) IBOutlet StatsViewController* statsController;
  @property (assign) NSString* challengeTitle;
  
  -(NSString*)checkChallenge:(int)challegeID;
  
  @end
  </code></pre>
  
  <p>in the .m</p>
  
  <pre><code>#import "GameChallenges.h"
  #import "StatsViewController.h"
  
  @implementation GameChallenges
  @synthesize challengeTitle,statsController;
  
  -(NSString*)checkChallenge:(int)challegeID{
      if(challegeID==1){
          self.challengeTitle = @"Some Text.";
          return challengeTitle;
      }else if(challegeID==2){
          self.challengeTitle = @"Some Other Text.";
          return challengeTitle;
      }
  }
  </code></pre>
  
  <p>From a view controller called StatsViewController I am calling this method</p>
  
  <p>in the .h</p>
  
  <pre><code>@class GameChallenges;
  
  @interface StatsViewController : UIViewController {
  
          UILabel* challengeIDDescText;
  }
  
  
  @property (nonatomic, retain) IBOutlet UILabel* challengeIDDescText;
  
  @property (nonatomic, retain) IBOutlet GameChallenges* challenges;
  
  @end
  </code></pre>
  
  <p>in the .m</p>
  
  <pre><code>[challenges checkChallenge:tempString];
  challengeIDDescText.text = challenges.challengeTitle;
  </code></pre>