-1

我的应用程序因错误而崩溃:+ [AccountService createMockAccountData] 无法识别的选择器已发送到类 0x89e40 ..请告知我该如何解决此错误?我是 Objective 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);

谢谢!

4

2 回答 2

3

改变

+(NSMutableArray *)accounts: createMockAccountData{

+(NSMutableArray *)createMockAccountData{
于 2012-06-04T20:15:23.843 回答
2

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

 - (return type)name:(parameter type)parameterName 
于 2012-06-04T20:14:38.283 回答