CTR ли единым? KPI в контекстной рекламеАлександр Егоров, Alytics.ru
Владимир Гричина (Componentix): "Не Swift`ом единым"
-
Upload
provectus -
Category
Technology
-
view
446 -
download
0
Transcript of Владимир Гричина (Componentix): "Не Swift`ом единым"
Почему не Swift
нестабильный toolchainплохая производительность toolchainсинтаксическая сольlegacy код на Objective-C
Что доступно в Objective-C?БлокиKVC Collection OperatorsNSPredicate
KVC Collection Operators
double totalPrice = 0;for (CartItem *item in self.cartItems) { totalPrice += item.price;}
vs[self.cartItems valueForKeyPath:@"@sum.price"];
Доступные операции@count, @sum, @avg, @max, @min@unionOfObjects, @distinctUnionOfObjects@unionOfArrays, @distinctUnionOfArrays, @distinctUnionOfSets
Примеры из жизни
[GNWebClient sharedInstance].selectedPlatforms = [[GNWebClient sharedInstance].platforms valueForKeyPath:@"platformId"];[GNWebClient sharedInstance].selectedSources = [[GNWebClient sharedInstance].sources valueForKeyPath:@"sourceId"];
[self preloadResources: [self.diseaseInfo valueForKeyPath: @"@distinctUnionOfArrays.allResourceURLs"]];[self preloadResources: [self.contactsMsd valueForKeyPath:@"photo"]];
int score = [[self.questions valueForKeyPath:@"@sum.currentScore"] intValue];
NSPredicateNSMutableArray *result = [NSMutableArray array];for (CartItem *item in self.cartItems) { if (item.price > 100) { [result addObject:item]; }}return [NSArray arrayWithArray:result];
vsreturn [NSArray filteredArrayWithPredicate: [NSPredicate predicateWithFormat:@"price < %@", @100]];
Доступные операцииСравнение (=, ==, >=, =>, <=, =>, <, >, !=, <>, BETWEEN)Логические операции (AND, &&, OR, ||, NOT, !)Операции со строками (BEGINSWITH, CONTAINS, ENDSWITH, LIKE,MATCHES)Операции с коллекциями (ANY, SOME, NONE, IN)Операции с массивами (array[index], array[FIRST],array[LAST], array[SIZE])
Примеры из жизни
NSArray *imageEnclosures = [self.feedItem.enclosures filteredArrayUsingPredicate: [NSPredicate predicateWithFormat:@"type like 'image/*'"]];
`
GMSAddress *address = [addressInfo.results filteredArrayUsingPredicate: [NSPredicate predicateWithFormat: @"thoroughfare MATCHES %@", @"[\\d-]+ .+"]].firstObject;
- (BOOL)mwResult{ NSArray *mandatoryQuestions = [self.allQuestions filteredArrayUsingPredicate: [NSPredicate predicateWithFormat:@"mw = %@", @"Mandatory"]]; NSArray *optionalQuestions = [self.allQuestions filteredArrayUsingPredicate: [NSPredicate predicateWithFormat:@"mw = %@", @"Optional"]];
NSPredicate *answerIsYes = [NSPredicate predicateWithFormat: @"answer = %d", QuestionAnswerYes];
NSArray *mandatoryIsYes = [mandatoryQuestions filteredArrayUsingPredicate:answerIsYes]; NSArray *optionalIsYes = [optionalQuestions filteredArrayUsingPredicate:answerIsYes]; return mandatoryIsYes.count == mandatoryQuestions.count && optionalIsYes.count > 0;}
Ваши вопросы?
Спасибо за вниманиеВладимир Гричина[email protected]