【发布时间】:2012-03-13 03:17:36
【问题描述】:
我在一个单独的文件中的一个类中有一个相当简单的方法,它接受一个整数,在 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: 所在的位置。但是可能会发生其他事情,因此将整个头文件添加到您的原始问题中。
-
在
nextURL=行下断点,查看sceneChanger的值。它可能为零。
标签: objective-c methods xcode4.2 call nsurl