Search code examples
ioscocoa-touchin-app-purchasensset

iphone: why my in-app purchase product array object index set automatically in alphabetical order


I am working on in-app purchase task in app I done all work currently but I need one help that my product array display in UITableview with sorting in alphabetical but I need display as same a my productIdentifiers how can I do this stuff please help

My issue example below:-

I set my product productIdentifiers like

- (id)init 
{
   NSSet *productIdentifiers = [NSSet setWithObjects:
                                   @"com.myapp.calculation.c",
                                   @"com.myapp.calculation.d",
                                   @"com.myapp.calculation.a",
                                   @"com.myapp.calculation.s",
                                   @"com.myapp.calculation.b",
                                   @"com.myapp.calculation.h",
                                   nil];

    if ((self = [super initWithProductIdentifiers:productIdentifiers])) 
    {                

    }

    return self;
}   

and in tableview data display on cell alphabetical sorting with a b c d h s

but i need it display as same as productIdentifiers like c d a s b h

Please help.


Solution

  • Expanding on Adam's comment above, if you are trying to display data from a collection class in a table view, you should use an array as the data source, not a set. This is because the objects contained within an NSArray are automatically ordered, based on how the objects are placed into the array, and so will come out in that order. With an NSSet the contents are unordered and thus will come out in any order.

    Take a look at Apple's Values and Collections document, which gives details of the three main types of collection class available in Cocoa: NSArray, NSSet and NSDictionary.