无法识别的选择器发送到类 0x89e40



我的应用程序崩溃并显示错误:+[AccountService createMockAccountData] 无法识别的选择器发送到类 0x89e40..请告知如何解决此错误?我是目标 C 的新手。这是我的代码:

@interface AccountService : NSObject
+ (NSMutableArray *)accounts: createMockAccountData;
@end

#import AccountService.h"
@implementation AccountService
+(NSMutableArray *)accounts: createMockAccountData{
    NSMutableArray * accounts = [[NSMutableArray alloc] init];
    UserAccount *mockUserAccount1 = [[UserAccount alloc] init];
    *mockUserAccount1 setName:@"Stella"];
    [accounts addObject:mockUserAccount1];
    UserAccount *mockUserAccount2  = [[UserAccount alloc] init];
    [mockUserAccount2 setName:@"Marko"];
    [accounts addObject:mockUserAccount2];
    [mockUserAccount1 release];
    [mockUserAccount2 release];
    return accounts;
}

....

在我的控制器中...我像这样调用这个类方法:

NSMutableArray *accounts = [AccountService createMockAccountData];
NSUInteger count = [accounts count];
NSLog(@"# of records = %d",count);

谢谢!

更改

+(NSMutableArray *)accounts: createMockAccountData{

+(NSMutableArray *)createMockAccountData{

你的语法搞砸了。方法标头如下所示:

 - (return type)name:(parameter type)parameterName 

最新更新