我正在开发我的第一个真正的 iPhone 应用程序,一个简单的待办事项列表应用程序来帮助我组织东西,除了我得到一个“发送到实例 0x 的无法识别的选择器”。
具体来说:
2010-02-20 14:30:09.200 ToDoApp[88562:20b] *** -[NSCFDictionary switchViews:]: unrecognized selector sent to instance 0x3d22de0
2010-02-20 14:30:09.201 ToDoApp[88562:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFDictionary switchViews:]: unrecognized selector sent to instance 0x3d22de0'
我环顾四周,发现这可能是 IB 中的连接问题,但我对整个连接的东西还是新手(伙计,我希望他们支持 Java 或 Python),所以这是它的布局方式。我有 3 个类,一个 SwitchViewController、一个 MainScreenViewController 和一个 ToDoListViewController。当我点击 MainScreenViewController 上的按钮时,我触发了引发此问题的“switchViews”功能。他们设置它的方式是按钮(UIBarButtonItem)具有“sentAction”转到switchViews。这个 ViewButton 有它的参考出口,作为 SwitchViewController 中的一个 IBOutlet。
所以这里是 SVC 的 .h:
#import <UIKit/UIKit.h>
@class MainScreenViewController;
@class ToDoListViewController;
@class EditViewController;
#define kMinimumGestureLength 25
#define kMaximumVariance 5
@interface SwitchViewController : UIViewController {
MainScreenViewController *mainScreenViewController;
ToDoListViewController *toDoListViewController;
EditViewController *editViewController;
IBOutlet UIBarButtonItem *viewButton;
CGPoint gestureStartPoint;
}
@property (retain, nonatomic) MainScreenViewController *mainScreenViewController;
@property (retain, nonatomic) ToDoListViewController *toDoListViewController;
@property (retain, nonatomic) EditViewController *editViewController;
@property (retain, nonatomic) IBOutlet UIBarButtonItem *viewButton;
@property CGPoint gestureStartPoint;
-(IBAction)switchViews:(id)sender;
对于 switchViews 功能:
-(IBAction) switchViews:(id)sender
{
NSLog(@"Switching views");
if(self.toDoListViewController.view.superview == nil){
if(self.toDoListViewController ==nil){
ToDoListViewController *toDoVC = [[ToDoListViewController alloc] initWithNibName:@"ToDoListView" bundle:nil];
self.toDoListViewController = toDoVC;
//[toDoVC release];
}
[mainScreenViewController.view removeFromSuperview];
[self.view insertSubview:toDoListViewController.view atIndex:0];
}
else{
if(self.mainScreenViewController == nil){
MainScreenViewController *mainController = [[MainScreenViewController alloc] initWithNibName:@"MainScreenView" bundle:nil];
self.mainScreenViewController = mainController;
//[mainController release];
}
[toDoListViewController.view removeFromSuperview];
[self.view insertSubview:mainScreenViewController.view atIndex:0];
}
}
所以简而言之,我完全迷失了,这真的很令人沮丧。任何人有任何建议,或需要更多的代码?