我在一個單獨的文件中的類中有一個相當簡單的方法,它接受一個整數,在一個case select中查找它,並返回一個對應於它的NSURL指針。它有以下方法:方法不被調用
#import <Foundation/Foundation.h>
@interface ChangeCurrentScene : NSObject
{
NSString *filePath;
NSURL *url;
int currentScene;
}
- (NSURL *)changeSceneURL:(int)toDesiredScene;
@end
我不知道100%如何,我應該從外部調用它,但我有一個按鈕,在我的故事板,這肯定工程掛鉤,和我使用這條線把它稱爲:
nextURL = [sceneChanger changeSceneURL:1];
從這個頭文件:
@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
我把一個斷點在changeSceneURL的第一行:toDesiredScene類,但它不叫的。沒有崩潰,但沒有電話。首先,這是使用被調用方法返回的正確方法嗎? nextURL是一個NSURL對象,我希望將返回的值存儲在其中。其次,該方法根本不會被調用的原因是什麼?我真的很難過,但我確信這是一件非常簡單的事情。
謝謝,提前!
您可以顯示名爲sceneChanger對象的頭文件?該對象應該是方法changeSceneURL:所在的位置。但其他事情可能會發生,所以將整個頭文件添加到您的原始問題。 – Jim 2012-02-22 18:37:32
在'nextURL ='行放置一個斷點,並檢查sceneChanger的值。它可能是零。 – jrturton 2012-02-22 18:37:46