我想從類方法訪問實例方法。我收到此錯誤Objective-C從類方法調用方法
+ ActiveVC goToDashBoard]:無法識別的選擇發送到類0x112010
***終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因是:「+ [ActiveVC goToDashBoard]: 無法識別的選擇發送到類0x112010'
我的代碼
+ (void) removeClosedVisitor:(NSString *) visitorID{
for (NSInteger i = activelist.count - 1; i >= 0 ; i--) {
ActiveItemObject *item = [activelist objectAtIndex:i];
if ([visitorID isEqualToString:item.VisitorId]) {
NSLog(@"Removing Visitor from Active List -- %@", visitorID);
[activelist removeObjectAtIndex:i];
//[self.incommingTable reloadData];
// NSDictionary *activeDictionary = [[NSDictionary alloc] init];
// activeDictionary = [activelist mutableCopy];
//
// [[NSNotificationCenter defaultCenter]
// postNotificationName:@"PassData"
// object:nil
// userInfo:activeDictionary];
[[self class] goToDashBoard];
}
}
}
- (void) goToDashBoard{
NSLog(@"Segue to Dashboard");
UITabBarController *dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"id_tabView"];
[dvc setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:dvc animated:YES completion:nil];
}
有人可以幫我解決這個問題。 TNX。
' - (void)goToDashBoard'是一個實例方法。如果你想使它成爲一個類方法,不帶實例的可訪問性,將簽名更改爲'+(void)goToDashBoard' – NSNoob