Swift filter array using NSPredicate
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an application written in Swift that is pulling in the users contacts from their address book. I want to filter out the contact that only contain a company name (so that you get your "assumed" real person contact and not businesses) Here is how this is being accomplish in the Objective-C version of my app: NSArray *allContacts = (__bridge_transfer NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook); NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id person, NSDictionary *bindings) { NSString *firstName =