0

我不明白为什么这段代码会抛出 Bad Access 异常:

- (void)viewDidLoad
{

TheUserEntity* userEntity = [TheUserEntity alloc];

TheUserModel* userModel = [TheUserModel alloc];

userEntity = [userModel Read:1];

    [super viewDidLoad];
}

TheUserEntity 和 TheUserModel 是我自己的类,1 只有属性,其他只有 CRUD 方法

有什么帮助吗?我是iOS开发新手,谢谢

4

1 回答 1

3

你必须调用init你的对象:

TheUserEntity* userEntity = [[TheUserEntity alloc] init];
TheUserModel* userModel = [[TheUserModel alloc] init];

您的方法名称应以小写字母开头,这是惯例。

于 2012-06-28T00:53:04.497 回答