Created
June 14, 2019 11:06
-
-
Save chaitanyaSoni96/16fadd73043baf3cf093d343e7a73334 to your computer and use it in GitHub Desktop.
Array filter ObjC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// fillterDataClass.m | |
// SellQwik | |
// | |
// Created by Admin on 27/03/19. | |
// | |
#import "fillterDataClass.h" | |
#import "CatalogCategoryAssignedProductsData.h" | |
@implementation fillterDataClass | |
NSMutableArray *brandArray; | |
NSMutableArray *categoryArray; | |
-(NSMutableArray*)arrayFilterdataBrandData:(NSMutableArray*)allProductArray | |
{ | |
brandArray = [[NSMutableArray alloc]init]; | |
for (CatalogCategoryAssignedProductsData *product in allProductArray) { | |
if ([self notContainsBrand:product]) { | |
[brandArray addObject:product]; | |
} | |
} | |
return brandArray; | |
} | |
-(BOOL)notContainsBrand:(CatalogCategoryAssignedProductsData*)product | |
{ | |
BOOL contains=YES; | |
if ([brandArray count] > 0) { | |
for (CatalogCategoryAssignedProductsData *data in brandArray) { | |
if ([data.brandValue caseInsensitiveCompare:product.brandValue] != NSOrderedSame && product.brandValue != nil) { | |
contains = YES; | |
} | |
else{ | |
contains = NO; | |
} | |
} | |
} | |
else{ | |
contains=YES; | |
} | |
return contains; | |
} | |
-(NSMutableArray *)arrayFilterDataCategoryData:(NSMutableArray *)allProductArray :(NSString *)selectedBrand{ | |
categoryArray = [[NSMutableArray alloc]init]; | |
for (CatalogCategoryAssignedProductsData *data in allProductArray){ | |
if([data.brandValue caseInsensitiveCompare:selectedBrand] == NSOrderedSame){ | |
[categoryArray addObject:data]; | |
} | |
} | |
return categoryArray; | |
} | |
-(NSMutableArray*)arrayFilterBrandAndCategory:(NSMutableArray*)categoryArray:(NSString*)selectedCategory | |
{ | |
NSMutableArray *fillterCategoryArray = [[NSMutableArray alloc]init]; | |
for (CatalogCategoryAssignedProductsData *data in categoryArray) { | |
if ([data.categoryValue caseInsensitiveCompare:selectedCategory] == NSOrderedSame) { | |
[fillterCategoryArray addObject:data]; | |
} | |
} | |
return fillterCategoryArray; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment