jeudi 15 janvier 2015

How to use output of code?

The code below gives the output of screenId and count of each screenId.


Once a screenId gets to a certain count say 10 I would like to perform an action. Would I be using an "If" statement? New to all this and not sure how to get started here.


Thank you!



NSCountedSet *totalScans = [NSCountedSet setWithArray:appDelegate.scannedNumbers];
NSMutableArray *dictArray = [NSMutableArray array];
for (NSNumber *num in totalScans) {
NSDictionary *dict = @{@"screenId":num,
@"count":@( [totalScans countForObject:num] )};
[dictArray addObject:dict];
}

NSArray *final =
[dictArray sortedArrayUsingDescriptors:
@[[NSSortDescriptor sortDescriptorWithKey:@"ScreenId" ascending:YES]]];

NSLog(@"%@",final);


Console Output:



count = 7;
screenId = 2402E58B73513EFEE08F5DE;

count = 6;
screenId = 9DBC162802A290BD31107B6;

count = 4;
screenId = 9729C8A8C7DCFCBFEE1BFD6;

Aucun commentaire:

Enregistrer un commentaire