gpt4 book ai didi

ios - 枚举值未正确显示

转载 作者:行者123 更新时间:2023-11-29 01:16:24 27 4
gpt4 key购买 nike

在我的 A 类中。我正在使用 Enum Like this。

typedef enum {
EditProfile,
CreateProfile,
} AdressState;

@interface ManageAddress : UIViewController<UITableViewDataSource,UITableViewDelegate,UIGestureRecognizerDelegate>
{
AdressState state;
}

并在.m文件中赋值

-(IBAction)adress:(id)sender
{
state = CreateProfile;
MyAddress *my = [[MyAddress alloc]initWithNibName:@"MyAddress" bundle:nil];
[self.navigationController pushViewController:my animated:YES];
}

在我的 MyAddressController 上,我正在访问枚举值

@interface MyAddress : UIViewController<UITextFieldDelegate,UITextViewDelegate>
{
AdressState state;
}

.m文件

if (state == EditProfile )
{
mobile.text = [[NSUserDefaults standardUserDefaults]objectForKey:@"mobile"];
}

我的状态总是显示 EditProfile 但我分配了一个值 CreateProfile。请帮忙。

最佳答案

您需要将 ManageAddressstate 成员变量的值分配给 MyAddressstate > 成员变量,因为它们都在不同的类中。只需将您的 (IBAction)adress:(id)sender 方法更新为以下内容:

-(IBAction)adress:(id)sender{
state = CreateProfile;
MyAddress *my =[[MyAddress alloc]initWithNibName:@"MyAddress" bundle:nil];
my.state = state;
[self.navigationController pushViewController:my animated:YES];

关于ios - 枚举值未正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35128959/

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