I am trying to iterate through a Dictionary to trim unacknowledged entries. Swift 3 translation of the following Objective-C code does not work:
[[self sharingDictionary] enumerateKeysAndObjectsUsingBlock: ^(id key, id obj, BOOL *stop) { SharingElement* element=[[self sharingDictionary] objectForKey:key]; if (!element.confirmed){ dispatch_async(dispatch_get_main_queue(), ^{ [element deleteMe]; }); [[self sharingDictionary] performSelector:@selector(removeObjectForKey:) withObject:key afterDelay:.2]; } else{ element.confirmed=NO; }];
And so I tried using the following compact numumerated () method as follows:
for (key, element) in self.sharingDictionary.enumerated(){ if (!element.confirmed){ element.deleteMe() self.perform(#selector(self.removeSharingInArray(key:)), with:key, afterDelay:0.2); } else{ element.confirmed=false } }
However, the compiler reports the following error while processing the use of the variable 'element':
Value of type tuple '(key: Int, value: SharingElement)' does not have a member 'Confirmed'
Like the "element", he took a full motorcade, than part of his competence. Is there a problem when using enumeration () or processing a dictionary and how can I fix it?
source share