Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从parse.com获取不同的值_Ios_Parse Platform - Fatal编程技术网

Ios 从parse.com获取不同的值

Ios 从parse.com获取不同的值,ios,parse-platform,Ios,Parse Platform,我有一个parse.com后端和一些表: shop product shopHasProduct Shop:Shop Pointer; Product:Product pointer; + some fields relation to shop-specific info 所以shopHasProduct是一个多对多表 我需要的是获得shopHasProduct表中没有的特定商店的所有产品 到目前为止,我所做的是在shopHasProduct表上查询: 这让我得到了所有不在当前

我有一个parse.com后端和一些表:

shop
product
shopHasProduct
  Shop:Shop Pointer;
  Product:Product pointer; 
  + some fields relation to shop-specific info
所以shopHasProduct是一个多对多表

我需要的是获得shopHasProduct表中没有的特定商店的所有产品

到目前为止,我所做的是在shopHasProduct表上查询:

这让我得到了所有不在当前商店的产品。但是每个商店都有这些产品,所以它们会再次出现

如何对它们进行排序以使它们不同?

我最终没有使用PFQueryTableViewController,而是使用普通的UITableViewController

在viewDidLoad中,我执行以下操作:

PFQuery *shopHasProductThisShop = [[PFQuery alloc] initWithClassName:@"shopHasProduct"];
[shopHasProductThisShop whereKey:@"Shop" equalTo:[[PFUser currentUser] objectForKey:@"currentShop"]];



PFQuery *hej = [[PFQuery alloc] initWithClassName:@"shopHasProduct"];
[hej whereKey:@"Product" doesNotMatchKey:@"Product" inQuery:shopHasProductThisShop];
[hej includeKey:@"Product"];

[hej findObjectsInBackgroundWithBlock:^(NSArray *allProducts, NSError *error) {

    self.productToAdd = [NSMutableArray new];
    self.productArray = [NSMutableArray new];
    NSLog(@"Hvor mange er der i alle prodikter'et:%d", [allProducts count]);

    for (PFObject *object in allProducts) {

        PFObject *random = object[@"Product"];
        [self.productArray addObject:random];

    }
    NSSet *uniqueStates = [NSSet setWithArray:[self.productArray valueForKey:@"objectId"]];

    NSArray *foobar = [uniqueStates allObjects];
    for (NSString *string in foobar) {
        PFObject *hulo = [PFQuery getObjectOfClass:@"Product" objectId:string];
        [self.productToAdd addObject:hulo];
    }  
   [self.tableView reloadData];
}];
所以我得到了一个只有不同产品的NSMutableArray

PFQuery *shopHasProductThisShop = [[PFQuery alloc] initWithClassName:@"shopHasProduct"];
[shopHasProductThisShop whereKey:@"Shop" equalTo:[[PFUser currentUser] objectForKey:@"currentShop"]];



PFQuery *hej = [[PFQuery alloc] initWithClassName:@"shopHasProduct"];
[hej whereKey:@"Product" doesNotMatchKey:@"Product" inQuery:shopHasProductThisShop];
[hej includeKey:@"Product"];

[hej findObjectsInBackgroundWithBlock:^(NSArray *allProducts, NSError *error) {

    self.productToAdd = [NSMutableArray new];
    self.productArray = [NSMutableArray new];
    NSLog(@"Hvor mange er der i alle prodikter'et:%d", [allProducts count]);

    for (PFObject *object in allProducts) {

        PFObject *random = object[@"Product"];
        [self.productArray addObject:random];

    }
    NSSet *uniqueStates = [NSSet setWithArray:[self.productArray valueForKey:@"objectId"]];

    NSArray *foobar = [uniqueStates allObjects];
    for (NSString *string in foobar) {
        PFObject *hulo = [PFQuery getObjectOfClass:@"Product" objectId:string];
        [self.productToAdd addObject:hulo];
    }  
   [self.tableView reloadData];
}];