Skip to content

Instantly share code, notes, and snippets.

@chaitanyaSoni96
Last active July 1, 2020 07:02
Show Gist options
  • Save chaitanyaSoni96/14e12fd25540d5b550eabef98b49f08f to your computer and use it in GitHub Desktop.
Save chaitanyaSoni96/14e12fd25540d5b550eabef98b49f08f to your computer and use it in GitHub Desktop.
//logic
NSMutableArray* tempArray = [NSMutableArray new];
for (NSDictionary* custumerDetails in tempArrayCustomers) {
NSMutableDictionary *prunedDictionary = [NSMutableDictionary dictionary];
for (NSString * key in [custumerDetails allKeys])
{
if (![[custumerDetails objectForKey:key] isKindOfClass:[NSNull class]]){
[prunedDictionary setObject:[custumerDetails objectForKey:key] forKey:key];
}else{
[prunedDictionary setObject:@"" forKey:key];
}
}
[tempArray addObject:prunedDictionary];
}
tempArrayCustomers = [tempArray copy];
//method
-(NSMutableArray*)pruneArrayOfDictionaries:(NSMutableArray*)arrayToPrune{
NSMutableArray* tempArray = [NSMutableArray new];
for (NSDictionary* custumerDetails in arrayToPrune) {
NSMutableDictionary *prunedDictionary = [NSMutableDictionary dictionary];
for (NSString * key in [custumerDetails allKeys])
{
if (![[custumerDetails objectForKey:key] isKindOfClass:[NSNull class]]){
[prunedDictionary setObject:[custumerDetails objectForKey:key] forKey:key];
}else{
[prunedDictionary setObject:@"" forKey:key];
}
}
[tempArray addObject:prunedDictionary];
}
return tempArray;
}
for (key, value) in CustomerDetails{
let keyInDict = key as! String
if let valueInDict = value as? String{
}else{
CustomerDetails.setValue("", forKey: keyInDict)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment