-1
我學習iOS
的方法,並試圖建立一個實用工具類如下的Objective-C:不能實例化另一個類
COMMON.H
@interface Common
- (void) title: (NSString *) title withViewController: (UIViewController *) viewController;
@end
Common.m
#import "Common.h"
#import "PennyNavigationController.h"
@implementation Common
- (void)title:(NSString *)title withViewController:(UIViewController *)viewController {
viewController.title = title;
viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Menu"
style:UIBarButtonItemStyleBordered
target:(PennyNavigationController *) viewController.navigationController
action:@selector(showMenu)];
}
@end
然後我嘗試使用我的TableViewController
作爲
#import "Common.h"
- (void)viewDidLoad {
[super viewDidLoad];
Common *common = [[Common alloc] init];
}
我得到我的IDE作爲
Cannot resolve method 'alloc' for interface 'Common'
什麼我做錯了錯誤?