I am trying to add the product IDs in app purchase. But here in the following code I am adding it manually. How can I add it from a plist
?
My code:
@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;
}
Setup your plist as an array. Then load the NSArray
from the plist file. Then create the NSSet
from the NSArray
.
// 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];