gpt4 book ai didi

iphone - 为什么我会在这个简单的代码上收到 Bad Access 异常?

转载 作者:行者123 更新时间:2023-11-28 20:33:56 25 4
gpt4 key购买 nike

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

- (void)viewDidLoad
{

TheUserEntity* userEntity = [TheUserEntity alloc];

TheUserModel* userModel = [TheUserModel alloc];

userEntity = [userModel Read:1];

[super viewDidLoad];
}

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

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

最佳答案

你必须在你的对象上调用 init:

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

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

关于iphone - 为什么我会在这个简单的代码上收到 Bad Access 异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11236720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com