I have a fairly simple method in a class in a separate file, which takes in an integer, looks it up in a case select, and returns an NSURL pointer that corresponds to it. It has this method:
#import <Foundation/Foundation.h>
@interface ChangeCurrentScene : NSObject
{
NSString *filePath;
NSURL *url;
int currentScene;
}
- (NSURL *)changeSceneURL:(int)toDesiredScene;
@end
I’m not 100% sure how I’m supposed to call it from outside, but I have a button hooked up in my storyboard, which definitely works, and I’m using this line to call it:
nextURL = [sceneChanger changeSceneURL:1];
From this header file:
@interface MSViewController : UIViewController <AVAudioPlayerDelegate> {
BOOL userInputAvailable;
int currentScene;
NSURL *nextURL;
ChangeCurrentScene *sceneChanger;
}
@property (strong) AVAudioPlayer *menuPlayer;
@property (strong, nonatomic) IBOutlet UILabel *userChoiceLabel;
@property (strong, nonatomic) IBOutlet UIImageView *nowPlayingIcon;
- (BOOL) playScene : (NSURL *)fileToBePlayed;
@end
I’ve put a breakpoint on the first line of the changeSceneURL:toDesiredScene class, but it is not called at all. No crashes, but no calls either. First off, is this the correct way to use the return from a called method? nextURL is an NSURL object, and I want the returned value to be stored in it. Secondly, what reason would there be for the method not being called at all? I’m really stumped here, but I’m sure it’s something blindingly simple.
Thanks, in advance!
Chech that
sceneChangeris notnil. You can send messages tonil, but the method doesn’t get called.Edit You should initialize
sceneChangersomewhere like this: