3

アプリの購入で製品 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;
}
4

2 に答える 2

3

plist を配列としてセットアップします。NSArray次に、plist ファイルから をロードします。次に、NSSetから を作成します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];
于 2013-07-18T04:36:17.757 に答える
3

実際にplistファイルをNSSArrayにロードしてから、setWithArrayクラスメソッドを使用してNSArrayアイテムをNSSetにロードできます。これにより、配列から重複が削除され、アイテムが設定に追加されます。これがコードです。

NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"Sample" ofType:@"plist"];
NSArray * contentArray = [NSArray arrayWithContentsOfFile:plistPath];
NSSet * sampleSet = [NSSet setWithArray:contentArray];
于 2013-07-18T04:40:39.943 に答える