Objective c 方法未被调用
我在一个单独文件中的类中有一个相当简单的方法,它接受一个整数,在case select中查找它,并返回一个与之对应的NSURL指针。它有以下方法:Objective c 方法未被调用,objective-c,methods,xcode4.2,call,nsurl,Objective C,Methods,Xcode4.2,Call,Nsurl,我在一个单独文件中的类中有一个相当简单的方法,它接受一个整数,在case select中查找它,并返回一个与之对应的NSURL指针。它有以下方法: #import <Foundation/Foundation.h> @interface ChangeCurrentScene : NSObject { NSString *filePath; NSURL *url; int currentScene; } - (NSURL *)changeSceneURL:(
#import <Foundation/Foundation.h>
@interface ChangeCurrentScene : NSObject
{
NSString *filePath;
NSURL *url;
int currentScene;
}
- (NSURL *)changeSceneURL:(int)toDesiredScene;
@end
从该头文件:
@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
@接口MSViewController:UIViewController{
BOOL用户可输入;
内景;
NSURL*nextURL;
ChangeCurrentScene*场景更改;
}
@属性(强)AVAudioPlayer*menuPlayer;
@属性(强,非原子)IBUILabel*userChoiceLabel;
@属性(强,非原子)IBUIImageView*nowPlayingIcon;
-(BOOL)播放场景:(NSURL*)要显示的文件;
@结束
我在changeSceneURL:toDesiredScene类的第一行上放置了一个断点,但根本没有调用它。没有崩溃,但也没有电话。首先,这是使用从被调用方法返回的正确方法吗?nextURL是一个NSURL对象,我希望返回的值存储在其中。第二,该方法根本没有被调用的原因是什么?我真的被难住了,但我确信这是一件非常简单的事情
提前谢谢 检查
sceneChanger
是否为nil
。您可以将消息发送到nil
,但不会调用该方法
编辑您应该在如下位置初始化sceneChanger
:
sceneChanger = [[ChangeCurrentScene alloc] init];
检查
sceneChanger
是否为nil
。您可以将消息发送到nil
,但不会调用该方法
编辑您应该在如下位置初始化sceneChanger
:
sceneChanger = [[ChangeCurrentScene alloc] init];
能否显示名为sceneChanger的对象的头文件?该对象应该位于方法changeSceneURL:所在的位置。但是可能会发生其他事情,所以将整个头文件添加到原始问题中。在
nextur=
行上放置一个断点,然后检查sceneChanger的值。它可能是零。您能显示名为sceneChanger的对象的头文件吗?该对象应该位于方法changeSceneURL:所在的位置。但是可能会发生其他事情,所以将整个头文件添加到原始问题中。在nextur=
行上放置一个断点,然后检查sceneChanger的值。可能是零。是的,是零。我用“po sceneChanger”在gdb测试。如何为其赋值?我需要为其分配NSURL还是int?这是一个方法,我不知道一个方法有一个值。@lukech-不,sceneChanger
是一个对象,它是ChangeCurrentScene
的一个实例。是的,它是零。我用“po sceneChanger”在gdb测试。如何为其赋值?我需要为其分配NSURL还是int?这是一个方法,我不知道一个方法有一个值。@lukech-不,sceneChanger
是一个对象,它是ChangeCurrentScene
的一个实例。