gpt4 book ai didi

ios - 将 NSObject 转换为 NSDictionary

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:00:48 24 4
gpt4 key购买 nike

<分区>

如何将 NSObject 转换为 NSDictionary?

第一步,我已经将 NSDictionary 转换为 NSObject,例如,

QRCodeData *obj = [[QRCodeData alloc] initWithQRcodeData:myDictonary];

QRCodeData.h

@interface QRCodeData : NSObject
-(instancetype)initWithQRcodeData:(NSDictionary*)dictionary;
@end

QRCodeData.m

@implementation QRCodeData

-(instancetype)initWithQRcodeData:(NSDictionary*)dictionary
{
self = [super init];
if(self){

self.name = dictionary[@"userName"];
self.phoneNumber = dictionary[@"mobileNo"];

}
return self;

}
@end

我想从对象中得到我的字典,有可能得到吗?

请提前帮助并感谢..

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