gpt4 book ai didi

ios - 将数据从 plist 添加到 NSSet?

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:09:46 25 4
gpt4 key购买 nike

我正在尝试在应用购买中添加产品 ID。但是在下面的代码中,我手动添加了它。如何从 plist 添加它?

我的代码:

@implementation RageIAPHelper

+ (RageIAPHelper *)sharedInstance {
static dispatch_once_t once;
static RageIAPHelper * sharedInstance;
dispatch_once(&once, ^{
NSSet * productIdentifiers = [NSSet setWithObjects:
@"greatminds.assamkarttestingdays",
@"greatminds.newgirlinthecity",
@"greatminds.newlights",
nil];
sharedInstance = [[self alloc] initWithProductIdentifiers:productIdentifiers];
});
return sharedInstance;
}

最佳答案

将你的 plist 设置为一个数组。然后从 plist 文件加载 NSArray。然后从 NSArray 创建 NSSet

// Assume you have a plist in the app bundle named "products.plist" with a root of type array
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"products" ofType:@"plist"];
NSArray *products = [NSArray arrayWithContentsOfFile:filePath];
NSSet *productIdentifiers = [NSSet setWithArray:products];

关于ios - 将数据从 plist 添加到 NSSet?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17714557/

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