***由于未捕获的异常'NSInvalidArgumentException'而终止应用,

时间:2012-08-15 23:27:49

标签: ios selector

我是iOS的新手,我想实现启动画面并从数据库加载数据然后传输到另一个视图控制器以显示UITableView中的数据 这是我的代码

#import "SplashViewController.h"
#import "DataLoader.h"
#import "UISessionTable.h"
@interface SplashViewController ()  

@end
@implementation SplashViewController

@synthesize sessionsDataFromDatabase;





-(void) viewDidLoad{
    [super viewDidLoad];

   double  currentTime = [[NSDate date] timeIntervalSince1970];

    dispatch_queue_t downloadQueue = dispatch_queue_create("session data loader", NULL);
    dispatch_async(downloadQueue, ^{
        //code to load session into array

        self.sessionsDataFromDatabase = [DataLoader getSessions]; 
        dispatch_async(dispatch_get_main_queue(), ^{




            double differance = 5000.0 - ([[NSDate date] timeIntervalSince1970] - currentTime) ;


            differance = differance<0? 0:differance;

            [[NSTimer scheduledTimerWithTimeInterval: differance target:self
                                                              selector: @selector(pushToSessionTableViewController:) userInfo: nil repeats: NO]fire];

                    });
    });
    dispatch_release(downloadQueue);


}
-(void) viewDidUnload{
    [super viewDidUnload];
    self.sessionsDataFromDatabase = nil;
}
-(void) pushToSessionTableViewController{


    UISessionTable * obj = [[UISessionTable alloc]init ];

    [obj setSessionsData:self.sessionsDataFromDatabase];


    [self.navigationController pushViewController:obj animated:YES];



}
@end

运行时出现以下错误

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 
'-[SplashViewController pushToSessionTableViewController:]: unrecognized selector sent 
to instance 0x6e45740'

任何建议???

1 个答案:

答案 0 :(得分:2)

最后的冒号是用于接收参数的方法,您的方法不会收到任何参数。这就是为什么它找不到方法(假设它是另一种未声明的方法)。

替换

pushToSessionTableViewController:

pushToSessionTableViewController