diff --git a/Riot/AppDelegate.m b/Riot/AppDelegate.m index e49b0ed7b..e5c96e866 100644 --- a/Riot/AppDelegate.m +++ b/Riot/AppDelegate.m @@ -389,7 +389,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN NSLog(@"[AppDelegate] didFinishLaunchingWithOptions: isProtectedDataAvailable: %@", @([application isProtectedDataAvailable])); // Log app information - NSString *appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]; + NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; NSString* appVersion = [AppDelegate theDelegate].appVersion; NSString* build = [AppDelegate theDelegate].build; @@ -437,7 +437,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController; splitViewController.delegate = self; - _masterNavigationController = [splitViewController.viewControllers objectAtIndex:0]; + _masterNavigationController = splitViewController.viewControllers[0]; _masterTabBarController = _masterNavigationController.viewControllers.firstObject; // Force the background color of the fake view controller displayed when there is no details. @@ -1080,7 +1080,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN UIMutableUserNotificationCategory* quickReplyCategory = [[UIMutableUserNotificationCategory alloc] init]; quickReplyCategory.identifier = @"QUICK_REPLY"; - [quickReplyCategory setActions:[NSArray arrayWithObjects:quickReply, nil] forContext:UIUserNotificationActionContextDefault]; + [quickReplyCategory setActions:@[quickReply] forContext:UIUserNotificationActionContextDefault]; [notificationCategories addObject:quickReplyCategory]; } @@ -1144,7 +1144,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN else { [manager roomDataSourceForRoom:roomId create:YES onComplete:^(MXKRoomDataSource *roomDataSource) { - NSString* responseText = [responseInfo objectForKey:UIUserNotificationActionResponseTypedTextKey]; + NSString* responseText = responseInfo[UIUserNotificationActionResponseTypedTextKey]; if (responseText != nil && responseText.length != 0) { NSLog(@"[AppDelegate][Push] handleActionWithIdentifier: sending message to room: %@", roomId); @@ -2144,10 +2144,10 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN for (NSString *keyValue in [fragments[1] componentsSeparatedByString:@"&"]) { // Get the parameter name - NSString *key = [[keyValue componentsSeparatedByString:@"="] objectAtIndex:0]; + NSString *key = [keyValue componentsSeparatedByString:@"="][0]; // Get the parameter value - NSString *value = [[keyValue componentsSeparatedByString:@"="] objectAtIndex:1]; + NSString *value = [keyValue componentsSeparatedByString:@"="][1]; if (value.length) { value = [value stringByReplacingOccurrencesOfString:@"+" withString:@" "]; @@ -3777,7 +3777,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN callerDisplayname = event.sender; } - NSString *appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]; + NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; NSString *message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"no_voip", @"Vector", nil), callerDisplayname, appDisplayName]; diff --git a/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m b/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m index dabdb7af2..a0a916211 100644 --- a/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m +++ b/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m @@ -315,7 +315,7 @@ NSString *const kMXKRoomBubbleCellTapOnReceiptsContainer = @"kMXKRoomBubbleCellT - (void)setBlurred:(BOOL)blurred { - objc_setAssociatedObject(self, @selector(blurred), [NSNumber numberWithBool:blurred], OBJC_ASSOCIATION_RETAIN_NONATOMIC); + objc_setAssociatedObject(self, @selector(blurred), @(blurred), OBJC_ASSOCIATION_RETAIN_NONATOMIC); if (blurred) { diff --git a/Riot/Categories/MXRoom+Riot.m b/Riot/Categories/MXRoom+Riot.m index fc2533508..cc43e075a 100644 --- a/Riot/Categories/MXRoom+Riot.m +++ b/Riot/Categories/MXRoom+Riot.m @@ -32,7 +32,7 @@ if (self.accountData.tags && self.accountData.tags.count) { - oldTag = [self.accountData.tags.allKeys objectAtIndex:0]; + oldTag = self.accountData.tags.allKeys[0]; } // support only kMXRoomTagFavourite or kMXRoomTagLowPriority tags by now diff --git a/Riot/Managers/Analytics/Analytics.m b/Riot/Managers/Analytics/Analytics.m index a87b29315..552e9e0ab 100644 --- a/Riot/Managers/Analytics/Analytics.m +++ b/Riot/Managers/Analytics/Analytics.m @@ -103,7 +103,7 @@ NSString *const kAnalyticsE2eDecryptionFailureAction = @"Decryption failure"; - (void)trackScreen:(NSString *)screenName { // Use the same pattern as Android - NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]; + NSString *appName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; NSString *appVersion = [AppDelegate theDelegate].appVersion; [[PiwikTracker shared] trackWithView:@[@"ios", appName, appVersion, screenName] diff --git a/Riot/Modules/Authentication/AuthenticationViewController.m b/Riot/Modules/Authentication/AuthenticationViewController.m index cd16fe9d5..5aad8e64d 100644 --- a/Riot/Modules/Authentication/AuthenticationViewController.m +++ b/Riot/Modules/Authentication/AuthenticationViewController.m @@ -158,7 +158,7 @@ self.noFlowLabel.textColor = kRiotColorRed; NSMutableAttributedString *forgotPasswordTitle = [[NSMutableAttributedString alloc] initWithString:NSLocalizedStringFromTable(@"auth_forgot_password", @"Vector", nil)]; - [forgotPasswordTitle addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, forgotPasswordTitle.length)]; + [forgotPasswordTitle addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:NSMakeRange(0, forgotPasswordTitle.length)]; [forgotPasswordTitle addAttribute:NSForegroundColorAttributeName value:kRiotColorGreen range:NSMakeRange(0, forgotPasswordTitle.length)]; [self.forgotPasswordButton setAttributedTitle:forgotPasswordTitle forState:UIControlStateNormal]; [self.forgotPasswordButton setAttributedTitle:forgotPasswordTitle forState:UIControlStateHighlighted]; @@ -290,7 +290,7 @@ if (!countryCode) { // If none, consider the preferred locale - NSLocale *local = [[NSLocale alloc] initWithLocaleIdentifier:[[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]]; + NSLocale *local = [[NSLocale alloc] initWithLocaleIdentifier:[[NSBundle mainBundle] preferredLocalizations][0]]; if ([local respondsToSelector:@selector(countryCode)]) { countryCode = local.countryCode; diff --git a/Riot/Modules/Authentication/Views/AuthInputsView.m b/Riot/Modules/Authentication/Views/AuthInputsView.m index 9aa81ff8f..c35376819 100644 --- a/Riot/Modules/Authentication/Views/AuthInputsView.m +++ b/Riot/Modules/Authentication/Views/AuthInputsView.m @@ -1292,11 +1292,11 @@ // Retrieve the site key NSString *siteKey; - id recaptchaParams = [currentSession.params objectForKey:kMXLoginFlowTypeRecaptcha]; + id recaptchaParams = currentSession.params[kMXLoginFlowTypeRecaptcha]; if (recaptchaParams && [recaptchaParams isKindOfClass:NSDictionary.class]) { NSDictionary *recaptchaParamsDict = (NSDictionary*)recaptchaParams; - siteKey = [recaptchaParamsDict objectForKey:@"public_key"]; + siteKey = recaptchaParamsDict[@"public_key"]; } // Retrieve the REST client from delegate diff --git a/Riot/Modules/Call/CallViewController.m b/Riot/Modules/Call/CallViewController.m index b88a3e32b..5a9f710d4 100644 --- a/Riot/Modules/Call/CallViewController.m +++ b/Riot/Modules/Call/CallViewController.m @@ -127,7 +127,7 @@ CGColorRef opaqueWhiteColor = [UIColor colorWithWhite:white alpha:1.0].CGColor; CGColorRef transparentWhiteColor = [UIColor colorWithWhite:white alpha:0].CGColor; - gradientMaskLayer.colors = [NSArray arrayWithObjects:(__bridge id)opaqueWhiteColor, (__bridge id)transparentWhiteColor, nil]; + gradientMaskLayer.colors = @[(__bridge id) opaqueWhiteColor, (__bridge id) transparentWhiteColor]; gradientMaskLayer.bounds = CGRectMake(0, 0, self.callContainerView.frame.size.width, self.callContainerView.frame.size.height + 20); gradientMaskLayer.anchorPoint = CGPointZero; diff --git a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m index e228e2039..f7341486a 100644 --- a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m +++ b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m @@ -156,7 +156,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou // sanity check if (matrixSession.myUser && matrixSession.myUser.userId) { - id roomTagListener = [roomTagsListenerByUserId objectForKey:matrixSession.myUser.userId]; + id roomTagListener = roomTagsListenerByUserId[matrixSession.myUser.userId]; if (roomTagListener) { @@ -204,7 +204,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou }]; - [roomTagsListenerByUserId setObject:roomTagsListener forKey:dataSource.mxSession.myUser.userId]; + roomTagsListenerByUserId[dataSource.mxSession.myUser.userId] = roomTagsListener; } } } @@ -891,42 +891,42 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou { if (cellDataIndex < favoriteCellDataArray.count) { - cellData = [favoriteCellDataArray objectAtIndex:cellDataIndex]; + cellData = favoriteCellDataArray[cellDataIndex]; } } else if (tableSection == peopleSection) { if (cellDataIndex < peopleCellDataArray.count) { - cellData = [peopleCellDataArray objectAtIndex:cellDataIndex]; + cellData = peopleCellDataArray[cellDataIndex]; } } else if (tableSection== conversationSection) { if (cellDataIndex < conversationCellDataArray.count) { - cellData = [conversationCellDataArray objectAtIndex:cellDataIndex]; + cellData = conversationCellDataArray[cellDataIndex]; } } else if (tableSection == lowPrioritySection) { if (cellDataIndex < lowPriorityCellDataArray.count) { - cellData = [lowPriorityCellDataArray objectAtIndex:cellDataIndex]; + cellData = lowPriorityCellDataArray[cellDataIndex]; } } else if (tableSection == serverNoticeSection) { if (cellDataIndex < serverNoticeCellDataArray.count) { - cellData = [serverNoticeCellDataArray objectAtIndex:cellDataIndex]; + cellData = serverNoticeCellDataArray[cellDataIndex]; } } else if (tableSection == invitesSection) { if (cellDataIndex < invitesCellDataArray.count) { - cellData = [invitesCellDataArray objectAtIndex:cellDataIndex]; + cellData = invitesCellDataArray[cellDataIndex]; } } @@ -983,7 +983,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou { for (int index = 0; index < cellDataArray.count; index++) { - id cellDataStoring = [cellDataArray objectAtIndex:index]; + id cellDataStoring = cellDataArray[index]; if ([roomId isEqualToString:cellDataStoring.roomSummary.roomId] && (matrixSession == cellDataStoring.roomSummary.room.mxSession)) { @@ -1114,7 +1114,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou if (displayedRecentsDataSourceArray.count > 0) { // FIXME manage multi accounts - MXKSessionRecentsDataSource *recentsDataSource = [displayedRecentsDataSourceArray objectAtIndex:0]; + MXKSessionRecentsDataSource *recentsDataSource = displayedRecentsDataSourceArray[0]; MXSession* session = recentsDataSource.mxSession; NSInteger count = recentsDataSource.numberOfCells; diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index f0f54f16a..8e3d8da43 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -893,7 +893,7 @@ NSArray* tags = room.accountData.tags.allValues; if (tags.count) { - currentTag = [tags objectAtIndex:0]; + currentTag = tags[0]; } } diff --git a/Riot/Modules/Common/SegmentedViewController/SegmentedViewController.m b/Riot/Modules/Common/SegmentedViewController/SegmentedViewController.m index c4d5d4d12..d539f6ffa 100644 --- a/Riot/Modules/Common/SegmentedViewController/SegmentedViewController.m +++ b/Riot/Modules/Common/SegmentedViewController/SegmentedViewController.m @@ -243,7 +243,7 @@ // create programmatically each label UILabel *label = [[UILabel alloc] init]; - label.text = [sectionTitles objectAtIndex:index]; + label.text = sectionTitles[index]; label.font = [UIFont systemFontOfSize:17]; label.textAlignment = NSTextAlignmentCenter; label.textColor = _sectionHeaderTintColor; @@ -263,7 +263,7 @@ leftConstraint = [NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual - toItem:[labels objectAtIndex:(index-1)] + toItem:labels[index - 1] attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:0]; @@ -339,7 +339,7 @@ leftMarkerViewConstraint = [NSLayoutConstraint constraintWithItem:selectedMarkerView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual - toItem:[sectionLabels objectAtIndex:_selectedIndex] + toItem:sectionLabels[_selectedIndex] attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]; @@ -386,7 +386,7 @@ if (index != NSNotFound) { - UILabel* label = [sectionLabels objectAtIndex:index]; + UILabel* label = sectionLabels[index]; label.font = [UIFont systemFontOfSize:17]; } @@ -398,7 +398,7 @@ [NSLayoutConstraint deactivateConstraints:@[displayedVCTopConstraint, displayedVCLeftConstraint, displayedVCWidthConstraint, displayedVCHeightConstraint]]; } - UILabel* label = [sectionLabels objectAtIndex:_selectedIndex]; + UILabel* label = sectionLabels[_selectedIndex]; label.font = [UIFont boldSystemFontOfSize:17]; // update the marker view position @@ -407,7 +407,7 @@ leftMarkerViewConstraint = [NSLayoutConstraint constraintWithItem:selectedMarkerView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual - toItem:[sectionLabels objectAtIndex:_selectedIndex] + toItem:sectionLabels[_selectedIndex] attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]; @@ -415,7 +415,7 @@ [NSLayoutConstraint activateConstraints:@[leftMarkerViewConstraint]]; // Set the new selected view controller - _selectedViewController = [viewControllers objectAtIndex:_selectedIndex]; + _selectedViewController = viewControllers[_selectedIndex]; // Make iOS invoke selectedViewController viewWillAppear when the segmented view is already visible if (isViewAppeared) diff --git a/Riot/Modules/Communities/Members/GroupParticipantsViewController.m b/Riot/Modules/Communities/Members/GroupParticipantsViewController.m index ef7ba2360..da5f29271 100644 --- a/Riot/Modules/Communities/Members/GroupParticipantsViewController.m +++ b/Riot/Modules/Communities/Members/GroupParticipantsViewController.m @@ -161,7 +161,7 @@ [kRiotPrimaryBgColor getWhite:&white alpha:nil]; CGColorRef opaqueWhiteColor = [UIColor colorWithWhite:white alpha:1.0].CGColor; CGColorRef transparentWhiteColor = [UIColor colorWithWhite:white alpha:0].CGColor; - tableViewMaskLayer.colors = [NSArray arrayWithObjects:(__bridge id)transparentWhiteColor, (__bridge id)transparentWhiteColor, (__bridge id)opaqueWhiteColor, nil]; + tableViewMaskLayer.colors = @[(__bridge id) transparentWhiteColor, (__bridge id) transparentWhiteColor, (__bridge id) opaqueWhiteColor]; if (self.tableView.dataSource) { @@ -450,13 +450,12 @@ CGColorRef opaqueWhiteColor = [UIColor colorWithWhite:white alpha:1.0].CGColor; CGColorRef transparentWhiteColor = [UIColor colorWithWhite:white alpha:0].CGColor; - tableViewMaskLayer.colors = [NSArray arrayWithObjects:(__bridge id)transparentWhiteColor, (__bridge id)transparentWhiteColor, (__bridge id)opaqueWhiteColor, nil]; + tableViewMaskLayer.colors = @[(__bridge id) transparentWhiteColor, (__bridge id) transparentWhiteColor, (__bridge id) opaqueWhiteColor]; // display a gradient to the rencents bottom (20% of the bottom of the screen) - tableViewMaskLayer.locations = [NSArray arrayWithObjects: - [NSNumber numberWithFloat:0], - [NSNumber numberWithFloat:0.85], - [NSNumber numberWithFloat:1.0], nil]; + tableViewMaskLayer.locations = @[@0.0F, + @0.85F, + @1.0F]; tableViewMaskLayer.bounds = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); tableViewMaskLayer.anchorPoint = CGPointZero; @@ -540,11 +539,11 @@ // List all the participants matrix user id to ignore them during the contacts search. for (Contact *contact in actualParticipants) { - [contactsDataSource.ignoredContactsByMatrixId setObject:contact forKey:contact.mxGroupUser.userId]; + contactsDataSource.ignoredContactsByMatrixId[contact.mxGroupUser.userId] = contact; } for (Contact *contact in invitedParticipants) { - [contactsDataSource.ignoredContactsByMatrixId setObject:contact forKey:contact.mxGroupUser.userId]; + contactsDataSource.ignoredContactsByMatrixId[contact.mxGroupUser.userId] = contact; } [contactsPickerViewController showSearch:YES]; diff --git a/Riot/Modules/Contacts/DataSources/ContactsDataSource.m b/Riot/Modules/Contacts/DataSources/ContactsDataSource.m index b0ac22827..b78d14dd4 100644 --- a/Riot/Modules/Contacts/DataSources/ContactsDataSource.m +++ b/Riot/Modules/Contacts/DataSources/ContactsDataSource.m @@ -375,7 +375,7 @@ NSArray *identifiers = contact.matrixIdentifiers; if (identifiers.count) { - if ([_ignoredContactsByMatrixId objectForKey:identifiers.firstObject]) + if (_ignoredContactsByMatrixId[identifiers.firstObject]) { [unfilteredLocalContacts removeObjectAtIndex:index]; continue; @@ -396,7 +396,7 @@ MXKEmail *email = emails.firstObject; // Trick: ignore @facebook.com email addresses from the results - facebook have discontinued that service... - if ([_ignoredContactsByEmail objectForKey:email.emailAddress] || [email.emailAddress hasSuffix:@"@facebook.com"]) + if (_ignoredContactsByEmail[email.emailAddress] || [email.emailAddress hasSuffix:@"@facebook.com"]) { [unfilteredLocalContacts removeObjectAtIndex:index]; continue; @@ -434,7 +434,7 @@ { for (NSString *userId in identifiers) { - if ([_ignoredContactsByMatrixId objectForKey:userId] == nil) + if (_ignoredContactsByMatrixId[userId] == nil) { MXKContact *splitContact = [[MXKContact alloc] initMatrixContactWithDisplayName:contact.displayName andMatrixID:userId]; [unfilteredMatrixContacts addObject:splitContact]; @@ -444,7 +444,7 @@ else if (identifiers.count) { NSString *userId = identifiers.firstObject; - if ([_ignoredContactsByMatrixId objectForKey:userId] == nil) + if (_ignoredContactsByMatrixId[userId] == nil) { [unfilteredMatrixContacts addObject:contact]; } diff --git a/Riot/Modules/Contacts/Details/ContactDetailsViewController.m b/Riot/Modules/Contacts/Details/ContactDetailsViewController.m index 3c40ccb57..3e264ba2c 100644 --- a/Riot/Modules/Contacts/Details/ContactDetailsViewController.m +++ b/Riot/Modules/Contacts/Details/ContactDetailsViewController.m @@ -727,7 +727,7 @@ if (indexPath.row < actionsArray.count) { - NSNumber *actionNumber = [actionsArray objectAtIndex:indexPath.row]; + NSNumber *actionNumber = actionsArray[indexPath.row]; NSString *title = [self actionButtonTitle:actionNumber.unsignedIntegerValue]; diff --git a/Riot/Modules/Home/HomeViewController.m b/Riot/Modules/Home/HomeViewController.m index 8c261b545..65d69eeb5 100644 --- a/Riot/Modules/Home/HomeViewController.m +++ b/Riot/Modules/Home/HomeViewController.m @@ -301,7 +301,7 @@ NSArray* tags = room.accountData.tags.allValues; if (tags.count) { - currentTag = [tags objectAtIndex:0]; + currentTag = tags[0]; } } diff --git a/Riot/Modules/MediaPicker/MediaPickerViewController.m b/Riot/Modules/MediaPicker/MediaPickerViewController.m index f0f30b847..ae3ceb3ba 100644 --- a/Riot/Modules/MediaPicker/MediaPickerViewController.m +++ b/Riot/Modules/MediaPicker/MediaPickerViewController.m @@ -306,7 +306,7 @@ static void *RecordingContext = &RecordingContext; - (void)checkDeviceAuthorizationStatus { - NSString *appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]; + NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; [MXKTools checkAccessForMediaType:AVMediaTypeVideo manualChangeMessage:[NSString stringWithFormat:NSLocalizedStringFromTable(@"camera_access_not_granted", @"Vector", nil), appDisplayName] @@ -1324,7 +1324,7 @@ static void *RecordingContext = &RecordingContext; - (void)caughtAVRuntimeError:(NSNotification*)note { - NSError *error = [[note userInfo] objectForKey:AVCaptureSessionErrorKey]; + NSError *error = [note userInfo][AVCaptureSessionErrorKey]; NSLog(@"[MediaPickerVC] AV Session Error: %@", error); dispatch_async(dispatch_get_main_queue(), ^{ @@ -1838,7 +1838,7 @@ static void *RecordingContext = &RecordingContext; { if (validationView) { - validationView.image = [[notification userInfo] objectForKey:MPMoviePlayerThumbnailImageKey]; + validationView.image = [notification userInfo][MPMoviePlayerThumbnailImageKey]; [validationView bringSubviewToFront:videoPlayerControl]; // Now, there is a thumbnail, show the video control diff --git a/Riot/Modules/Room/CellData/RoomBubbleCellData.m b/Riot/Modules/Room/CellData/RoomBubbleCellData.m index 55aa3051e..81cbef55f 100644 --- a/Riot/Modules/Room/CellData/RoomBubbleCellData.m +++ b/Riot/Modules/Room/CellData/RoomBubbleCellData.m @@ -275,7 +275,7 @@ static NSAttributedString *readReceiptVerticalWhitespace = nil; for (; index < bubbleComponents.count; index++) { // Compute the vertical position for next component - component = [bubbleComponents objectAtIndex:index]; + component = bubbleComponents[index]; component.position = CGPointMake(0, positionY); @@ -316,7 +316,7 @@ static NSAttributedString *readReceiptVerticalWhitespace = nil; for (index++; index < bubbleComponents.count; index++) { // Compute the vertical position for next component - component = [bubbleComponents objectAtIndex:index]; + component = bubbleComponents[index]; if (component.attributedTextMessage) { diff --git a/Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m b/Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m index 5b88317b3..3a9827614 100644 --- a/Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m +++ b/Riot/Modules/Room/Members/Detail/RoomMemberDetailsViewController.m @@ -754,11 +754,11 @@ NSNumber *actionNumber; if (indexPath.section == adminToolsIndex && indexPath.row < adminActionsArray.count) { - actionNumber = [adminActionsArray objectAtIndex:indexPath.row]; + actionNumber = adminActionsArray[indexPath.row]; } else if (indexPath.section == otherActionsIndex && indexPath.row < otherActionsArray.count) { - actionNumber = [otherActionsArray objectAtIndex:indexPath.row]; + actionNumber = otherActionsArray[indexPath.row]; } if (actionNumber) diff --git a/Riot/Modules/Room/Members/RoomParticipantsViewController.m b/Riot/Modules/Room/Members/RoomParticipantsViewController.m index 3a3fefa6a..0712a7169 100644 --- a/Riot/Modules/Room/Members/RoomParticipantsViewController.m +++ b/Riot/Modules/Room/Members/RoomParticipantsViewController.m @@ -173,7 +173,7 @@ [kRiotPrimaryBgColor getWhite:&white alpha:nil]; CGColorRef opaqueWhiteColor = [UIColor colorWithWhite:white alpha:1.0].CGColor; CGColorRef transparentWhiteColor = [UIColor colorWithWhite:white alpha:0].CGColor; - tableViewMaskLayer.colors = [NSArray arrayWithObjects:(__bridge id)transparentWhiteColor, (__bridge id)transparentWhiteColor, (__bridge id)opaqueWhiteColor, nil]; + tableViewMaskLayer.colors = @[(__bridge id) transparentWhiteColor, (__bridge id) transparentWhiteColor, (__bridge id) opaqueWhiteColor]; if (self.tableView.dataSource) { @@ -581,13 +581,12 @@ CGColorRef opaqueWhiteColor = [UIColor colorWithWhite:white alpha:1.0].CGColor; CGColorRef transparentWhiteColor = [UIColor colorWithWhite:white alpha:0].CGColor; - tableViewMaskLayer.colors = [NSArray arrayWithObjects:(__bridge id)transparentWhiteColor, (__bridge id)transparentWhiteColor, (__bridge id)opaqueWhiteColor, nil]; + tableViewMaskLayer.colors = @[(__bridge id) transparentWhiteColor, (__bridge id) transparentWhiteColor, (__bridge id) opaqueWhiteColor]; // display a gradient to the rencents bottom (20% of the bottom of the screen) - tableViewMaskLayer.locations = [NSArray arrayWithObjects: - [NSNumber numberWithFloat:0], - [NSNumber numberWithFloat:0.85], - [NSNumber numberWithFloat:1.0], nil]; + tableViewMaskLayer.locations = @[@0.0F, + @0.85F, + @1.0F]; tableViewMaskLayer.bounds = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); tableViewMaskLayer.anchorPoint = CGPointZero; @@ -671,18 +670,18 @@ // List all the participants matrix user id to ignore them during the contacts search. for (Contact *contact in actualParticipants) { - [contactsDataSource.ignoredContactsByMatrixId setObject:contact forKey:contact.mxMember.userId]; + contactsDataSource.ignoredContactsByMatrixId[contact.mxMember.userId] = contact; } for (Contact *contact in invitedParticipants) { if (contact.mxMember) { - [contactsDataSource.ignoredContactsByMatrixId setObject:contact forKey:contact.mxMember.userId]; + contactsDataSource.ignoredContactsByMatrixId[contact.mxMember.userId] = contact; } } if (userParticipant) { - [contactsDataSource.ignoredContactsByMatrixId setObject:userParticipant forKey:userParticipant.mxMember.userId]; + contactsDataSource.ignoredContactsByMatrixId[userParticipant.mxMember.userId] = userParticipant; } [contactsPickerViewController showSearch:YES]; diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index fea0b3ca0..09fdb31a0 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -2233,7 +2233,7 @@ [self cancelEventSelection]; - NSArray *activityItems = [NSArray arrayWithObjects:selectedComponent.textMessage, nil]; + NSArray *activityItems = @[selectedComponent.textMessage]; UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil]; @@ -2974,7 +2974,7 @@ { // Create the contact related to this member MXKContact *contact = [[MXKContact alloc] initMatrixContactWithDisplayName:mxMember.displayname andMatrixID:mxMember.userId]; - [contactsDataSource.ignoredContactsByMatrixId setObject:contact forKey:mxMember.userId]; + contactsDataSource.ignoredContactsByMatrixId[mxMember.userId] = contact; } } @@ -3080,7 +3080,7 @@ { __weak __typeof(self) weakSelf = self; - NSString *appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]; + NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; // Check app permissions first [MXKTools checkAccessForCall:video @@ -3400,7 +3400,7 @@ [super scrollViewWillBeginDragging:scrollView]; } - if (self.expandedHeaderContainer.isHidden == NO) + if (!self.expandedHeaderContainer.isHidden) { // Store here the position of the first touch down event UIPanGestureRecognizer *panGestureRecognizer = scrollView.panGestureRecognizer; @@ -3728,7 +3728,7 @@ // keeps the only the first two users for(int i = 0; i < MIN(count, 2); i++) { - NSString* name = [currentTypingUsers objectAtIndex:i]; + NSString* name = currentTypingUsers[i]; MXRoomMember* member = [self.roomDataSource.roomState.members memberWithUserId:name]; @@ -3750,15 +3750,15 @@ } else if (1 == names.count) { - text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_one_user_is_typing", @"Vector", nil), [names objectAtIndex:0]]; + text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_one_user_is_typing", @"Vector", nil), names[0]]; } else if (2 == names.count) { - text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_two_users_are_typing", @"Vector", nil), [names objectAtIndex:0], [names objectAtIndex:1]]; + text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_two_users_are_typing", @"Vector", nil), names[0], names[1]]; } else { - text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_many_users_are_typing", @"Vector", nil), [names objectAtIndex:0], [names objectAtIndex:1]]; + text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_many_users_are_typing", @"Vector", nil), names[0], names[1]]; } [((RoomActivitiesView*) self.activitiesView) displayTypingNotification:text]; @@ -3985,7 +3985,7 @@ NSLog(@"[RoomVC] onOngoingConferenceCallPressed (jitsi)"); __weak __typeof(self) weakSelf = self; - NSString *appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]; + NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; // Check app permissions first [MXKTools checkAccessForCall:video diff --git a/Riot/Modules/Room/Settings/RoomSettingsViewController.m b/Riot/Modules/Room/Settings/RoomSettingsViewController.m index e3fcf752a..565d656dc 100644 --- a/Riot/Modules/Room/Settings/RoomSettingsViewController.m +++ b/Riot/Modules/Room/Settings/RoomSettingsViewController.m @@ -713,9 +713,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti NSString *currentCanonicalAlias = mxRoomState.canonicalAlias; NSString *canonicalAlias; - if ([updatedItemsDict objectForKey:kRoomSettingsCanonicalAliasKey]) + if (updatedItemsDict[kRoomSettingsCanonicalAliasKey]) { - canonicalAlias = [updatedItemsDict objectForKey:kRoomSettingsCanonicalAliasKey]; + canonicalAlias = updatedItemsDict[kRoomSettingsCanonicalAliasKey]; } else { @@ -849,7 +849,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti if (directoryVisibilitySwitch) { // Check a potential user's change before the end of the request - MXRoomDirectoryVisibility modifiedDirectoryVisibility = [updatedItemsDict objectForKey:kRoomSettingsDirectoryKey]; + MXRoomDirectoryVisibility modifiedDirectoryVisibility = updatedItemsDict[kRoomSettingsDirectoryKey]; if (modifiedDirectoryVisibility) { if ([modifiedDirectoryVisibility isEqualToString:directoryVisibility]) @@ -882,7 +882,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti // Refresh here the related communities list. [relatedGroups removeAllObjects]; [relatedGroups addObjectsFromArray:mxRoomState.relatedGroups]; - NSArray *removedCommunities = [updatedItemsDict objectForKey:kRoomSettingsRemovedRelatedGroupKey]; + NSArray *removedCommunities = updatedItemsDict[kRoomSettingsRemovedRelatedGroupKey]; if (removedCommunities.count) { for (NSUInteger index = 0; index < relatedGroups.count;) @@ -900,7 +900,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } } } - NSArray *communities = [updatedItemsDict objectForKey:kRoomSettingsNewRelatedGroupKey]; + NSArray *communities = updatedItemsDict[kRoomSettingsNewRelatedGroupKey]; if (communities) { [relatedGroups addObjectsFromArray:communities]; @@ -947,7 +947,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti // Check whether the topic has been actually changed if ((topic || currentTopic) && ([topic isEqualToString:currentTopic] == NO)) { - [updatedItemsDict setObject:(topic ? topic : @"") forKey:kRoomSettingsTopicKey]; + updatedItemsDict[kRoomSettingsTopicKey] = topic ? topic : @""; } else { @@ -1098,7 +1098,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti // Check whether the name has been actually changed if ((displayName || currentName) && ([displayName isEqualToString:currentName] == NO)) { - [updatedItemsDict setObject:(displayName ? displayName : @"") forKey:kRoomSettingsNameKey]; + updatedItemsDict[kRoomSettingsNameKey] = displayName ? displayName : @""; } else { @@ -1187,10 +1187,10 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti // check if there is some updates related to room state if (mxRoomState) { - if ([updatedItemsDict objectForKey:kRoomSettingsAvatarKey]) + if (updatedItemsDict[kRoomSettingsAvatarKey]) { // Retrieve the current picture and make sure its orientation is up - UIImage *updatedPicture = [MXKTools forceImageOrientationUp:[updatedItemsDict objectForKey:kRoomSettingsAvatarKey]]; + UIImage *updatedPicture = [MXKTools forceImageOrientationUp:updatedItemsDict[kRoomSettingsAvatarKey]]; // Upload picture uploader = [MXMediaManager prepareUploaderWithMatrixSession:mxRoom.mxSession initialRange:0 andRange:1.0]; @@ -1204,7 +1204,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti self->uploader = nil; [self->updatedItemsDict removeObjectForKey:kRoomSettingsAvatarKey]; - [self->updatedItemsDict setObject:url forKey:kRoomSettingsAvatarURLKey]; + self->updatedItemsDict[kRoomSettingsAvatarURLKey] = url; [self onSave:nil]; } @@ -1236,7 +1236,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti return; } - NSString* photoUrl = [updatedItemsDict objectForKey:kRoomSettingsAvatarURLKey]; + NSString* photoUrl = updatedItemsDict[kRoomSettingsAvatarURLKey]; if (photoUrl) { pendingOperation = [mxRoom setAvatar:photoUrl success:^{ @@ -1278,7 +1278,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } // has a new room name - NSString* roomName = [updatedItemsDict objectForKey:kRoomSettingsNameKey]; + NSString* roomName = updatedItemsDict[kRoomSettingsNameKey]; if (roomName) { pendingOperation = [mxRoom setName:roomName success:^{ @@ -1320,7 +1320,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } // has a new room topic - NSString* roomTopic = [updatedItemsDict objectForKey:kRoomSettingsTopicKey]; + NSString* roomTopic = updatedItemsDict[kRoomSettingsTopicKey]; if (roomTopic) { pendingOperation = [mxRoom setTopic:roomTopic success:^{ @@ -1362,7 +1362,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } // Room guest access - MXRoomGuestAccess guestAccess = [updatedItemsDict objectForKey:kRoomSettingsGuestAccessKey]; + MXRoomGuestAccess guestAccess = updatedItemsDict[kRoomSettingsGuestAccessKey]; if (guestAccess) { pendingOperation = [mxRoom setGuestAccess:guestAccess success:^{ @@ -1404,7 +1404,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } // Room join rule - MXRoomJoinRule joinRule = [updatedItemsDict objectForKey:kRoomSettingsJoinRuleKey]; + MXRoomJoinRule joinRule = updatedItemsDict[kRoomSettingsJoinRuleKey]; if (joinRule) { pendingOperation = [mxRoom setJoinRule:joinRule success:^{ @@ -1446,7 +1446,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } // History visibility - MXRoomHistoryVisibility visibility = [updatedItemsDict objectForKey:kRoomSettingsHistoryVisibilityKey]; + MXRoomHistoryVisibility visibility = updatedItemsDict[kRoomSettingsHistoryVisibilityKey]; if (visibility) { pendingOperation = [mxRoom setHistoryVisibility:visibility success:^{ @@ -1488,7 +1488,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } // Room addresses - NSMutableArray *aliases = [updatedItemsDict objectForKey:kRoomSettingsNewAliasesKey]; + NSMutableArray *aliases = updatedItemsDict[kRoomSettingsNewAliasesKey]; if (aliases.count) { NSString *roomAlias = aliases.firstObject; @@ -1504,7 +1504,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti if (aliases.count > 1) { [aliases removeObjectAtIndex:0]; - [self->updatedItemsDict setObject:aliases forKey:kRoomSettingsNewAliasesKey]; + self->updatedItemsDict[kRoomSettingsNewAliasesKey] = aliases; } else { @@ -1541,7 +1541,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti return; } - aliases = [updatedItemsDict objectForKey:kRoomSettingsRemovedAliasesKey]; + aliases = updatedItemsDict[kRoomSettingsRemovedAliasesKey]; if (aliases.count) { NSString *roomAlias = aliases.firstObject; @@ -1557,7 +1557,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti if (aliases.count > 1) { [aliases removeObjectAtIndex:0]; - [self->updatedItemsDict setObject:aliases forKey:kRoomSettingsRemovedAliasesKey]; + self->updatedItemsDict[kRoomSettingsRemovedAliasesKey] = aliases; } else { @@ -1594,7 +1594,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti return; } - NSString* canonicalAlias = [updatedItemsDict objectForKey:kRoomSettingsCanonicalAliasKey]; + NSString* canonicalAlias = updatedItemsDict[kRoomSettingsCanonicalAliasKey]; if (canonicalAlias) { pendingOperation = [mxRoom setCanonicalAlias:canonicalAlias success:^{ @@ -1636,7 +1636,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } // Related groups - if ([updatedItemsDict objectForKey:kRoomSettingsNewRelatedGroupKey] || [updatedItemsDict objectForKey:kRoomSettingsRemovedRelatedGroupKey]) + if (updatedItemsDict[kRoomSettingsNewRelatedGroupKey] || updatedItemsDict[kRoomSettingsRemovedRelatedGroupKey]) { [self refreshRelatedGroups]; @@ -1683,7 +1683,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } // Update here other room settings - NSString *roomTag = [updatedItemsDict objectForKey:kRoomSettingsTagKey]; + NSString *roomTag = updatedItemsDict[kRoomSettingsTagKey]; if (roomTag) { if (!roomTag.length) @@ -1706,9 +1706,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti return; } - if ([updatedItemsDict objectForKey:kRoomSettingsMuteNotifKey]) + if (updatedItemsDict[kRoomSettingsMuteNotifKey]) { - if (((NSNumber*)[updatedItemsDict objectForKey:kRoomSettingsMuteNotifKey]).boolValue) + if (((NSNumber*) updatedItemsDict[kRoomSettingsMuteNotifKey]).boolValue) { [mxRoom mentionsOnly:^{ @@ -1739,9 +1739,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti return; } - if ([updatedItemsDict objectForKey:kRoomSettingsDirectChatKey]) + if (updatedItemsDict[kRoomSettingsDirectChatKey]) { - pendingOperation = [mxRoom setIsDirect:((NSNumber*)[updatedItemsDict objectForKey:kRoomSettingsDirectChatKey]).boolValue withUserId:nil success:^{ + pendingOperation = [mxRoom setIsDirect:((NSNumber*) updatedItemsDict[kRoomSettingsDirectChatKey]).boolValue withUserId:nil success:^{ if (weakSelf) { @@ -1752,7 +1752,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti [self onSave:nil]; } - } failure:^(NSError *error) { + } failure:^(NSError *error) { NSLog(@"[RoomSettingsViewController] Altering DMness failed"); @@ -1779,7 +1779,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } // Room directory visibility - MXRoomDirectoryVisibility directoryVisibility = [updatedItemsDict objectForKey:kRoomSettingsDirectoryKey]; + MXRoomDirectoryVisibility directoryVisibility = updatedItemsDict[kRoomSettingsDirectoryKey]; if (directoryVisibility) { [mxRoom setDirectoryVisibility:directoryVisibility success:^{ @@ -1820,7 +1820,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } // Room encryption - if ([updatedItemsDict objectForKey:kRoomSettingsEncryptionKey]) + if (updatedItemsDict[kRoomSettingsEncryptionKey]) { pendingOperation = [mxRoom enableEncryptionWithAlgorithm:kMXCryptoMegolmAlgorithm success:^{ @@ -1862,7 +1862,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } // Room settings on blacklist unverified devices - if ([updatedItemsDict objectForKey:kRoomSettingsEncryptionBlacklistUnverifiedDevicesKey]) + if (updatedItemsDict[kRoomSettingsEncryptionBlacklistUnverifiedDevicesKey]) { BOOL blacklistUnverifiedDevices = [((NSNumber*)updatedItemsDict[kRoomSettingsEncryptionBlacklistUnverifiedDevicesKey]) boolValue]; [mxRoom.mxSession.crypto setBlacklistUnverifiedDevicesInRoom:mxRoom.roomId blacklist:blacklistUnverifiedDevices]; @@ -1884,7 +1884,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti [roomAddresses removeAllObjects]; localAddressesCount = 0; - NSArray *removedAliases = [updatedItemsDict objectForKey:kRoomSettingsRemovedAliasesKey]; + NSArray *removedAliases = updatedItemsDict[kRoomSettingsRemovedAliasesKey]; NSArray *aliases = mxRoomState.aliases; if (aliases) @@ -1908,7 +1908,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } } - aliases = [updatedItemsDict objectForKey:kRoomSettingsNewAliasesKey]; + aliases = updatedItemsDict[kRoomSettingsNewAliasesKey]; for (NSString *alias in aliases) { // Add this new alias to local addresses @@ -1938,7 +1938,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti count = ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_SUB_COUNT; // Check whether a room address is required for the current join rule - NSString *joinRule = [updatedItemsDict objectForKey:kRoomSettingsJoinRuleKey]; + NSString *joinRule = updatedItemsDict[kRoomSettingsJoinRuleKey]; if (!joinRule) { // Use the actual values if no change is pending. @@ -2126,9 +2126,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti roomNotifCell.mxkLabel.text = NSLocalizedStringFromTable(@"room_details_mute_notifs", @"Vector", nil); - if ([updatedItemsDict objectForKey:kRoomSettingsMuteNotifKey]) + if (updatedItemsDict[kRoomSettingsMuteNotifKey]) { - roomNotifCell.mxkSwitch.on = ((NSNumber*)[updatedItemsDict objectForKey:kRoomSettingsMuteNotifKey]).boolValue; + roomNotifCell.mxkSwitch.on = ((NSNumber*) updatedItemsDict[kRoomSettingsMuteNotifKey]).boolValue; } else { @@ -2145,9 +2145,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti roomDirectChat.mxkLabel.text = NSLocalizedStringFromTable(@"room_details_direct_chat", @"Vector", nil); - if ([updatedItemsDict objectForKey:kRoomSettingsDirectChatKey]) + if (updatedItemsDict[kRoomSettingsDirectChatKey]) { - roomDirectChat.mxkSwitch.on = ((NSNumber*)[updatedItemsDict objectForKey:kRoomSettingsDirectChatKey]).boolValue; + roomDirectChat.mxkSwitch.on = ((NSNumber*) updatedItemsDict[kRoomSettingsDirectChatKey]).boolValue; } else { @@ -2179,9 +2179,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti roomPhotoCell.mxkLabel.text = NSLocalizedStringFromTable(@"room_details_photo", @"Vector", nil); roomPhotoCell.mxkLabel.textColor = kRiotPrimaryTextColor; - if ([updatedItemsDict objectForKey:kRoomSettingsAvatarKey]) + if (updatedItemsDict[kRoomSettingsAvatarKey]) { - roomPhotoCell.mxkImageView.image = (UIImage*)[updatedItemsDict objectForKey:kRoomSettingsAvatarKey]; + roomPhotoCell.mxkImageView.image = (UIImage*) updatedItemsDict[kRoomSettingsAvatarKey]; } else { @@ -2203,9 +2203,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti topicTextView = roomTopicCell.textView; - if ([updatedItemsDict objectForKey:kRoomSettingsTopicKey]) + if (updatedItemsDict[kRoomSettingsTopicKey]) { - topicTextView.text = (NSString*)[updatedItemsDict objectForKey:kRoomSettingsTopicKey]; + topicTextView.text = (NSString*) updatedItemsDict[kRoomSettingsTopicKey]; } else { @@ -2247,9 +2247,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti nameTextField.textAlignment = NSTextAlignmentRight; nameTextField.delegate = self; - if ([updatedItemsDict objectForKey:kRoomSettingsNameKey]) + if (updatedItemsDict[kRoomSettingsNameKey]) { - nameTextField.text = (NSString*)[updatedItemsDict objectForKey:kRoomSettingsNameKey]; + nameTextField.text = (NSString*) updatedItemsDict[kRoomSettingsNameKey]; } else { @@ -2285,9 +2285,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti label.textColor = kRiotPrimaryTextColor; label.text = NSLocalizedStringFromTable(@"room_details_low_priority_tag", @"Vector", nil); - if ([updatedItemsDict objectForKey:kRoomSettingsTagKey]) + if (updatedItemsDict[kRoomSettingsTagKey]) { - NSString *roomTag = [updatedItemsDict objectForKey:kRoomSettingsTagKey]; + NSString *roomTag = updatedItemsDict[kRoomSettingsTagKey]; if ([roomTag isEqualToString:kMXRoomTagFavourite]) { [roomTagCell setCheckBoxValue:YES atIndex:0]; @@ -2338,9 +2338,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti [directoryToggleCell.mxkSwitch addTarget:self action:@selector(toggleDirectoryVisibility:) forControlEvents:UIControlEventValueChanged]; - if ([updatedItemsDict objectForKey:kRoomSettingsDirectoryKey]) + if (updatedItemsDict[kRoomSettingsDirectoryKey]) { - directoryToggleCell.mxkSwitch.on = ((NSNumber*)[updatedItemsDict objectForKey:kRoomSettingsDirectoryKey]).boolValue; + directoryToggleCell.mxkSwitch.on = ((NSNumber*) updatedItemsDict[kRoomSettingsDirectoryKey]).boolValue; } else { @@ -2375,8 +2375,8 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti roomAccessCell.checkBoxLeadingConstraint.constant = roomAccessCell.separatorInset.left; // Retrieve the potential updated values for joinRule and guestAccess - NSString *joinRule = [updatedItemsDict objectForKey:kRoomSettingsJoinRuleKey]; - NSString *guestAccess = [updatedItemsDict objectForKey:kRoomSettingsGuestAccessKey]; + NSString *joinRule = updatedItemsDict[kRoomSettingsJoinRuleKey]; + NSString *guestAccess = updatedItemsDict[kRoomSettingsGuestAccessKey]; // Use the actual values if no change is pending if (!joinRule) @@ -2427,7 +2427,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti historyVisibilityCell.checkBoxLeadingConstraint.constant = historyVisibilityCell.separatorInset.left; // Retrieve first the potential updated value for history visibility - NSString *visibility = [updatedItemsDict objectForKey:kRoomSettingsHistoryVisibilityKey]; + NSString *visibility = updatedItemsDict[kRoomSettingsHistoryVisibilityKey]; // Use the actual value if no change is pending if (!visibility) @@ -2442,7 +2442,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti historyVisibilityCell.enabled = ([visibility isEqualToString:kMXRoomHistoryVisibilityWorldReadable]); - [historyVisibilityTickCells setObject:historyVisibilityCell forKey:kMXRoomHistoryVisibilityWorldReadable]; + historyVisibilityTickCells[kMXRoomHistoryVisibilityWorldReadable] = historyVisibilityCell; } else if (indexPath.row == ROOM_SETTINGS_HISTORY_VISIBILITY_SECTION_ROW_MEMBERS_ONLY) { @@ -2451,7 +2451,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti historyVisibilityCell.enabled = ([visibility isEqualToString:kMXRoomHistoryVisibilityShared]); - [historyVisibilityTickCells setObject:historyVisibilityCell forKey:kMXRoomHistoryVisibilityShared]; + historyVisibilityTickCells[kMXRoomHistoryVisibilityShared] = historyVisibilityCell; } else if (indexPath.row == ROOM_SETTINGS_HISTORY_VISIBILITY_SECTION_ROW_MEMBERS_ONLY_SINCE_INVITED) { @@ -2460,7 +2460,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti historyVisibilityCell.enabled = ([visibility isEqualToString:kMXRoomHistoryVisibilityInvited]); - [historyVisibilityTickCells setObject:historyVisibilityCell forKey:kMXRoomHistoryVisibilityInvited]; + historyVisibilityTickCells[kMXRoomHistoryVisibilityInvited] = historyVisibilityCell; } else if (indexPath.row == ROOM_SETTINGS_HISTORY_VISIBILITY_SECTION_ROW_MEMBERS_ONLY_SINCE_JOINED) { @@ -2469,7 +2469,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti historyVisibilityCell.enabled = ([visibility isEqualToString:kMXRoomHistoryVisibilityJoined]); - [historyVisibilityTickCells setObject:historyVisibilityCell forKey:kMXRoomHistoryVisibilityJoined]; + historyVisibilityTickCells[kMXRoomHistoryVisibilityJoined] = historyVisibilityCell; } // Check whether the user can change this option @@ -2544,9 +2544,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti NSString *alias = roomAddresses[row]; NSString *canonicalAlias; - if ([updatedItemsDict objectForKey:kRoomSettingsCanonicalAliasKey]) + if (updatedItemsDict[kRoomSettingsCanonicalAliasKey]) { - canonicalAlias = [updatedItemsDict objectForKey:kRoomSettingsCanonicalAliasKey]; + canonicalAlias = updatedItemsDict[kRoomSettingsCanonicalAliasKey]; } else { @@ -2690,7 +2690,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti { roomBlacklistUnverifiedDevicesCell.mxkSwitch.enabled = YES; - if ([updatedItemsDict objectForKey:kRoomSettingsEncryptionBlacklistUnverifiedDevicesKey]) + if (updatedItemsDict[kRoomSettingsEncryptionBlacklistUnverifiedDevicesKey]) { blacklistUnverifiedDevices = [((NSNumber*)updatedItemsDict[kRoomSettingsEncryptionBlacklistUnverifiedDevicesKey]) boolValue]; } @@ -2737,7 +2737,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti roomEncryptionCell.mxkLabel.text = NSLocalizedStringFromTable(@"room_details_advanced_enable_e2e_encryption", @"Vector", nil); - roomEncryptionCell.mxkSwitch.on = ([updatedItemsDict objectForKey:kRoomSettingsEncryptionKey] != nil); + roomEncryptionCell.mxkSwitch.on = (updatedItemsDict[kRoomSettingsEncryptionKey] != nil); cell = roomEncryptionCell; } @@ -2886,7 +2886,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:kMXRoomJoinRuleInvite forKey:kRoomSettingsJoinRuleKey]; + updatedItemsDict[kRoomSettingsJoinRuleKey] = kMXRoomJoinRuleInvite; // Update guest access to allow guest on invitation. // Note: if guest_access is "forbidden" here, guests cannot join this room even if explicitly invited. @@ -2896,7 +2896,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:kMXRoomGuestAccessCanJoin forKey:kRoomSettingsGuestAccessKey]; + updatedItemsDict[kRoomSettingsGuestAccessKey] = kMXRoomGuestAccessCanJoin; } } @@ -2929,7 +2929,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:kMXRoomJoinRulePublic forKey:kRoomSettingsJoinRuleKey]; + updatedItemsDict[kRoomSettingsJoinRuleKey] = kMXRoomJoinRulePublic; } if ([mxRoomState.guestAccess isEqualToString:kMXRoomGuestAccessForbidden]) @@ -2938,7 +2938,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:kMXRoomGuestAccessForbidden forKey:kRoomSettingsGuestAccessKey]; + updatedItemsDict[kRoomSettingsGuestAccessKey] = kMXRoomGuestAccessForbidden; } } @@ -2971,7 +2971,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:kMXRoomJoinRulePublic forKey:kRoomSettingsJoinRuleKey]; + updatedItemsDict[kRoomSettingsJoinRuleKey] = kMXRoomJoinRulePublic; } if ([mxRoomState.guestAccess isEqualToString:kMXRoomGuestAccessCanJoin]) @@ -2980,7 +2980,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:kMXRoomGuestAccessCanJoin forKey:kRoomSettingsGuestAccessKey]; + updatedItemsDict[kRoomSettingsGuestAccessKey] = kMXRoomGuestAccessCanJoin; } } @@ -3201,7 +3201,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:historyVisibility forKey:kRoomSettingsHistoryVisibilityKey]; + updatedItemsDict[kRoomSettingsHistoryVisibilityKey] = historyVisibility; } [self getNavigationItem].rightBarButtonItem.enabled = (updatedItemsDict.count != 0); @@ -3259,7 +3259,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti // Remove the canonical address if (self->mxRoomState.canonicalAlias.length) { - [self->updatedItemsDict setObject:@"" forKey:kRoomSettingsCanonicalAliasKey]; + self->updatedItemsDict[kRoomSettingsCanonicalAliasKey] = @""; } else { @@ -3305,7 +3305,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti { [self getNavigationItem].rightBarButtonItem.enabled = YES; - [updatedItemsDict setObject:image forKey:kRoomSettingsAvatarKey]; + updatedItemsDict[kRoomSettingsAvatarKey] = image; [self refreshRoomSettings]; } @@ -3401,7 +3401,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:[NSNumber numberWithBool:theSwitch.on] forKey:kRoomSettingsMuteNotifKey]; + updatedItemsDict[kRoomSettingsMuteNotifKey] = @(theSwitch.on); } [self getNavigationItem].rightBarButtonItem.enabled = (updatedItemsDict.count != 0); @@ -3415,7 +3415,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:[NSNumber numberWithBool:theSwitch.on] forKey:kRoomSettingsDirectChatKey]; + updatedItemsDict[kRoomSettingsDirectChatKey] = @(theSwitch.on); } [self getNavigationItem].rightBarButtonItem.enabled = (updatedItemsDict.count != 0); @@ -3458,7 +3458,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti typeof(self) self = weakSelf; self->currentAlert = nil; - [self->updatedItemsDict setObject:@(YES) forKey:kRoomSettingsEncryptionKey]; + self->updatedItemsDict[kRoomSettingsEncryptionKey] = @(YES); [self getNavigationItem].rightBarButtonItem.enabled = self->updatedItemsDict.count; } @@ -3504,12 +3504,12 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:visibility forKey:kRoomSettingsDirectoryKey]; + updatedItemsDict[kRoomSettingsDirectoryKey] = visibility; } } else { - [updatedItemsDict setObject:visibility forKey:kRoomSettingsDirectoryKey]; + updatedItemsDict[kRoomSettingsDirectoryKey] = visibility; } [self getNavigationItem].rightBarButtonItem.enabled = (updatedItemsDict.count != 0); @@ -3526,7 +3526,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:alias forKey:kRoomSettingsCanonicalAliasKey]; + updatedItemsDict[kRoomSettingsCanonicalAliasKey] = alias; } NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:ROOM_SETTINGS_ROOM_ADDRESSES_SECTION_INDEX]; @@ -3559,9 +3559,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti { NSString *canonicalAlias; - if ([updatedItemsDict objectForKey:kRoomSettingsCanonicalAliasKey]) + if (updatedItemsDict[kRoomSettingsCanonicalAliasKey]) { - canonicalAlias = [updatedItemsDict objectForKey:kRoomSettingsCanonicalAliasKey]; + canonicalAlias = updatedItemsDict[kRoomSettingsCanonicalAliasKey]; } else { @@ -3582,7 +3582,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti else { // Check whether the alias has just been added - NSMutableArray *addedAlias = [updatedItemsDict objectForKey:kRoomSettingsNewAliasesKey]; + NSMutableArray *addedAlias = updatedItemsDict[kRoomSettingsNewAliasesKey]; if (addedAlias && [addedAlias indexOfObject:roomAlias] != NSNotFound) { [addedAlias removeObject:roomAlias]; @@ -3594,11 +3594,11 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - NSMutableArray *removedAlias = [updatedItemsDict objectForKey:kRoomSettingsRemovedAliasesKey]; + NSMutableArray *removedAlias = updatedItemsDict[kRoomSettingsRemovedAliasesKey]; if (!removedAlias) { removedAlias = [NSMutableArray array]; - [updatedItemsDict setObject:removedAlias forKey:kRoomSettingsRemovedAliasesKey]; + updatedItemsDict[kRoomSettingsRemovedAliasesKey] = removedAlias; } [removedAlias addObject:roomAlias]; @@ -3622,7 +3622,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti - (void)removeCommunity:(NSString*)groupId { // Check whether the alias has just been added - NSMutableArray *addedGroup = [updatedItemsDict objectForKey:kRoomSettingsNewRelatedGroupKey]; + NSMutableArray *addedGroup = updatedItemsDict[kRoomSettingsNewRelatedGroupKey]; if (addedGroup && [addedGroup indexOfObject:groupId] != NSNotFound) { [addedGroup removeObject:groupId]; @@ -3634,11 +3634,11 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - NSMutableArray *removedGroup = [updatedItemsDict objectForKey:kRoomSettingsRemovedRelatedGroupKey]; + NSMutableArray *removedGroup = updatedItemsDict[kRoomSettingsRemovedRelatedGroupKey]; if (!removedGroup) { removedGroup = [NSMutableArray array]; - [updatedItemsDict setObject:removedGroup forKey:kRoomSettingsRemovedRelatedGroupKey]; + updatedItemsDict[kRoomSettingsRemovedRelatedGroupKey] = removedGroup; } [removedGroup addObject:groupId]; @@ -3656,7 +3656,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti if ([MXTools isMatrixRoomAlias:roomAlias]) { // Check whether this alias has just been deleted - NSMutableArray *removedAlias = [updatedItemsDict objectForKey:kRoomSettingsRemovedAliasesKey]; + NSMutableArray *removedAlias = updatedItemsDict[kRoomSettingsRemovedAliasesKey]; if (removedAlias && [removedAlias indexOfObject:roomAlias] != NSNotFound) { [removedAlias removeObject:roomAlias]; @@ -3669,11 +3669,11 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti // Check whether this alias is not already defined for this room else if ([roomAddresses indexOfObject:roomAlias] == NSNotFound) { - NSMutableArray *addedAlias = [updatedItemsDict objectForKey:kRoomSettingsNewAliasesKey]; + NSMutableArray *addedAlias = updatedItemsDict[kRoomSettingsNewAliasesKey]; if (!addedAlias) { addedAlias = [NSMutableArray array]; - [updatedItemsDict setObject:addedAlias forKey:kRoomSettingsNewAliasesKey]; + updatedItemsDict[kRoomSettingsNewAliasesKey] = addedAlias; } [addedAlias addObject:roomAlias]; @@ -3693,7 +3693,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:roomAlias forKey:kRoomSettingsCanonicalAliasKey]; + updatedItemsDict[kRoomSettingsCanonicalAliasKey] = roomAlias; } if (missingAddressWarningIndex != -1) @@ -3746,7 +3746,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti if ([MXTools isMatrixGroupIdentifier:groupId]) { // Check whether this group has just been deleted - NSMutableArray *removedGroups = [updatedItemsDict objectForKey:kRoomSettingsRemovedRelatedGroupKey]; + NSMutableArray *removedGroups = updatedItemsDict[kRoomSettingsRemovedRelatedGroupKey]; if (removedGroups && [removedGroups indexOfObject:groupId] != NSNotFound) { [removedGroups removeObject:groupId]; @@ -3759,11 +3759,11 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti // Check whether this alias is not already defined for this room else if ([relatedGroups indexOfObject:groupId] == NSNotFound) { - NSMutableArray *addedGroup = [updatedItemsDict objectForKey:kRoomSettingsNewRelatedGroupKey]; + NSMutableArray *addedGroup = updatedItemsDict[kRoomSettingsNewRelatedGroupKey]; if (!addedGroup) { addedGroup = [NSMutableArray array]; - [updatedItemsDict setObject:addedGroup forKey:kRoomSettingsNewRelatedGroupKey]; + updatedItemsDict[kRoomSettingsNewRelatedGroupKey] = addedGroup; } [addedGroup addObject:groupId]; @@ -3819,7 +3819,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti { // The user wants to unselect this tag // Retrieve the current change on room tag (if any) - NSString *updatedRoomTag = [updatedItemsDict objectForKey:kRoomSettingsTagKey]; + NSString *updatedRoomTag = updatedItemsDict[kRoomSettingsTagKey]; // Check the actual tag on mxRoom if (mxRoom.accountData.tags[tappedRoomTag]) @@ -3827,7 +3827,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti // The actual tag must be updated, check whether another tag is already set if (!updatedRoomTag) { - [updatedItemsDict setObject:@"" forKey:kRoomSettingsTagKey]; + updatedItemsDict[kRoomSettingsTagKey] = @""; } } else if (updatedRoomTag && [updatedRoomTag isEqualToString:tappedRoomTag]) @@ -3835,7 +3835,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti // Cancel the updated tag, but take into account the cancellation of another tag when 'tappedRoomTag' was selected. if (mxRoom.accountData.tags.count) { - [updatedItemsDict setObject:@"" forKey:kRoomSettingsTagKey]; + updatedItemsDict[kRoomSettingsTagKey] = @""; } else { @@ -3856,7 +3856,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti } else { - [updatedItemsDict setObject:tappedRoomTag forKey:kRoomSettingsTagKey]; + updatedItemsDict[kRoomSettingsTagKey] = tappedRoomTag; } // Select the tapped tag diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index cd55bd79f..37441f08c 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -1224,7 +1224,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); { if ([AppDelegate theDelegate].mxSessions.count > 0) { - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXSession* session = [AppDelegate theDelegate].mxSessions[0]; count = session.ignoredUsers.count; } else @@ -1383,7 +1383,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); return cell; } - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXSession* session = [AppDelegate theDelegate].mxSessions[0]; MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject; if (section == SETTINGS_SECTION_SIGN_OUT_INDEX) @@ -1626,7 +1626,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); if (!countryCode) { // If none, consider the preferred locale - NSLocale *local = [[NSLocale alloc] initWithLocaleIdentifier:[[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]]; + NSLocale *local = [[NSLocale alloc] initWithLocaleIdentifier:[[NSBundle mainBundle] preferredLocalizations][0]]; if ([local respondsToSelector:@selector(countryCode)]) { countryCode = local.countryCode; @@ -1715,7 +1715,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); { MXKTableViewCell *globalInfoCell = [self getDefaultTableViewCell:tableView]; - NSString *appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]; + NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; globalInfoCell.textLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"settings_global_settings_info", @"Vector", nil), appDisplayName]; globalInfoCell.textLabel.numberOfLines = 0; @@ -1872,7 +1872,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); } NSString* countryCode = [[MXKAppSettings standardAppSettings] phonebookCountryCode]; - NSLocale *local = [[NSLocale alloc] initWithLocaleIdentifier:[[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]]; + NSLocale *local = [[NSLocale alloc] initWithLocaleIdentifier:[[NSBundle mainBundle] preferredLocalizations][0]]; NSString *countryName = [local displayNameForKey:NSLocaleCountryCode value:countryCode]; cell.textLabel.textColor = kRiotPrimaryTextColor; @@ -2086,7 +2086,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); } else if (row == LABS_CRYPTO_INDEX) { - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXSession* session = [AppDelegate theDelegate].mxSessions[0]; MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath]; @@ -2252,7 +2252,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); // Check whether this section is visible if ([AppDelegate theDelegate].mxSessions.count > 0) { - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXSession* session = [AppDelegate theDelegate].mxSessions[0]; if (session.ignoredUsers.count) { return NSLocalizedStringFromTable(@"settings_ignored_users", @"Vector", nil); @@ -2379,7 +2379,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); { if ([AppDelegate theDelegate].mxSessions.count > 0) { - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXSession* session = [AppDelegate theDelegate].mxSessions[0]; if (session.ignoredUsers.count == 0) { // Hide this section @@ -2411,7 +2411,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); { if ([AppDelegate theDelegate].mxSessions.count > 0) { - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXSession* session = [AppDelegate theDelegate].mxSessions[0]; if (session.ignoredUsers.count == 0) { // Hide this section @@ -2492,7 +2492,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); } else if (section == SETTINGS_SECTION_IGNORED_USERS_INDEX) { - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXSession* session = [AppDelegate theDelegate].mxSessions[0]; NSString *ignoredUserId; if (indexPath.row < session.ignoredUsers.count) @@ -2517,7 +2517,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); typeof(self) self = weakSelf; self->currentAlert = nil; - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXSession* session = [AppDelegate theDelegate].mxSessions[0]; // Remove the member from the ignored user list [self startActivityIndicator]; @@ -2794,7 +2794,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); __weak typeof(self) weakSelf = self; - NSString *appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]; + NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; currentAlert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:NSLocalizedStringFromTable(@"settings_on_denied_notification", @"Vector", nil), appDisplayName] message:nil preferredStyle:UIAlertControllerStyleAlert]; @@ -3048,7 +3048,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); { [self startActivityIndicator]; - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXSession* session = [AppDelegate theDelegate].mxSessions[0]; [session enableCrypto:switchButton.isOn success:^{ // When disabling crypto, reset the current device id as it cannot be reused. @@ -3478,7 +3478,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); // Dismiss the keyboard [newEmailTextField resignFirstResponder]; - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXSession* session = [AppDelegate theDelegate].mxSessions[0]; MXK3PID *new3PID = [[MXK3PID alloc] initWithMedium:kMX3PIDMediumEmail andAddress:newEmailTextField.text]; [new3PID requestValidationTokenWithMatrixRestClient:session.matrixRestClient isDuringRegistration:NO nextLink:nil success:^{ @@ -3569,7 +3569,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); // Dismiss the keyboard [newPhoneNumberCell.mxkTextField resignFirstResponder]; - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXSession* session = [AppDelegate theDelegate].mxSessions[0]; NSString *e164 = [[NBPhoneNumberUtil sharedInstance] format:newPhoneNumber numberFormat:NBEPhoneNumberFormatE164 error:nil]; NSString *msisdn; @@ -3635,7 +3635,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(void); { if ([AppDelegate theDelegate].mxSessions.count > 0) { - MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0]; + MXSession* session = [AppDelegate theDelegate].mxSessions[0]; MXMyUser* myUser = session.myUser; BOOL saveButtonEnabled = (nil != newAvatarImage); diff --git a/Riot/Modules/StartChat/StartChatViewController.m b/Riot/Modules/StartChat/StartChatViewController.m index d55a50f60..939d8f3cc 100644 --- a/Riot/Modules/StartChat/StartChatViewController.m +++ b/Riot/Modules/StartChat/StartChatViewController.m @@ -257,7 +257,7 @@ if (identifiers.count) { // Here the contact can only have one identifier - [contactsDataSource.ignoredContactsByMatrixId setObject:contact forKey:identifiers.firstObject]; + contactsDataSource.ignoredContactsByMatrixId[identifiers.firstObject] = contact; } else { @@ -266,7 +266,7 @@ { // Here the contact can only have one email MXKEmail *email = emails.firstObject; - [contactsDataSource.ignoredContactsByEmail setObject:contact forKey:email.emailAddress]; + contactsDataSource.ignoredContactsByEmail[email.emailAddress] = contact; } } isMultiUseNameByDisplayName[contact.displayName] = (isMultiUseNameByDisplayName[contact.displayName] ? @(YES) : @(NO)); @@ -274,7 +274,7 @@ if (userContact) { - [contactsDataSource.ignoredContactsByMatrixId setObject:userContact forKey:self.mainSession.myUser.userId]; + contactsDataSource.ignoredContactsByMatrixId[self.mainSession.myUser.userId] = userContact; } } diff --git a/Riot/Modules/TabBar/MasterTabBarController.m b/Riot/Modules/TabBar/MasterTabBarController.m index 1190e2ee6..ef16cd49a 100644 --- a/Riot/Modules/TabBar/MasterTabBarController.m +++ b/Riot/Modules/TabBar/MasterTabBarController.m @@ -74,11 +74,11 @@ // Do any additional setup after loading the view, typically from a nib. // Retrieve the all view controllers - _homeViewController = [self.viewControllers objectAtIndex:TABBAR_HOME_INDEX]; - _favouritesViewController = [self.viewControllers objectAtIndex:TABBAR_FAVOURITES_INDEX]; - _peopleViewController = [self.viewControllers objectAtIndex:TABBAR_PEOPLE_INDEX]; - _roomsViewController = [self.viewControllers objectAtIndex:TABBAR_ROOMS_INDEX]; - _groupsViewController = [self.viewControllers objectAtIndex:TABBAR_GROUPS_INDEX]; + _homeViewController = self.viewControllers[TABBAR_HOME_INDEX]; + _favouritesViewController = self.viewControllers[TABBAR_FAVOURITES_INDEX]; + _peopleViewController = self.viewControllers[TABBAR_PEOPLE_INDEX]; + _roomsViewController = self.viewControllers[TABBAR_ROOMS_INDEX]; + _groupsViewController = self.viewControllers[TABBAR_GROUPS_INDEX]; // Set the accessibility labels for all buttons #1842 [_settingsBarButtonItem setAccessibilityLabel:NSLocalizedStringFromTable(@"settings_title", @"Vector", nil)]; @@ -864,7 +864,7 @@ [currentAlert dismissViewControllerAnimated:NO completion:nil]; - NSString *appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]; + NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"]; currentAlert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:NSLocalizedStringFromTable(@"google_analytics_use_prompt", @"Vector", nil), appDisplayName] message:nil preferredStyle:UIAlertControllerStyleAlert]; diff --git a/Riot/Utils/AvatarGenerator.m b/Riot/Utils/AvatarGenerator.m index 3d8bcd1eb..8cfc959f6 100644 --- a/Riot/Utils/AvatarGenerator.m +++ b/Riot/Utils/AvatarGenerator.m @@ -164,12 +164,12 @@ static UILabel* backgroundLabel = nil; imageByKeyDict = [[NSMutableDictionary alloc] init]; } - UIImage* image = [imageByKeyDict objectForKey:key]; + UIImage* image = imageByKeyDict[key]; if (!image) { - image = [AvatarGenerator imageFromText:firstChar withBackgroundColor:[colorsList objectAtIndex:colorIndex]]; - [imageByKeyDict setObject:image forKey:key]; + image = [AvatarGenerator imageFromText:firstChar withBackgroundColor:colorsList[colorIndex]]; + imageByKeyDict[key] = image; } return image; @@ -190,7 +190,7 @@ static UILabel* backgroundLabel = nil; NSString* firstChar = [AvatarGenerator firstChar:(displayname ? displayname : itemId)]; NSUInteger colorIndex = [AvatarGenerator colorIndexForText:itemId]; - return [AvatarGenerator imageFromText:firstChar withBackgroundColor:[colorsList objectAtIndex:colorIndex] size:size andFontSize:fontSize]; + return [AvatarGenerator imageFromText:firstChar withBackgroundColor:colorsList[colorIndex] size:size andFontSize:fontSize]; } + (void)clear diff --git a/RiotShareExtension/Managers/ShareExtensionManager.m b/RiotShareExtension/Managers/ShareExtensionManager.m index 182a9481c..27927a0c8 100644 --- a/RiotShareExtension/Managers/ShareExtensionManager.m +++ b/RiotShareExtension/Managers/ShareExtensionManager.m @@ -837,7 +837,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) - (void)setIsLoaded:(BOOL)isLoaded { - NSNumber *number = [NSNumber numberWithBool:isLoaded]; + NSNumber *number = @(isLoaded); objc_setAssociatedObject(self, @selector(isLoaded), number, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } diff --git a/RiotShareExtension/Modules/Share/ShareViewController.m b/RiotShareExtension/Modules/Share/ShareViewController.m index 6f6b785f7..5d8aa81fd 100644 --- a/RiotShareExtension/Modules/Share/ShareViewController.m +++ b/RiotShareExtension/Modules/Share/ShareViewController.m @@ -102,7 +102,7 @@ else { NSDictionary *infoDictionary = [NSBundle mainBundle].infoDictionary; - NSString *bundleDisplayName = [infoDictionary objectForKey:@"CFBundleDisplayName"]; + NSString *bundleDisplayName = infoDictionary[@"CFBundleDisplayName"]; self.tittleLabel.text = bundleDisplayName; [self configureFallbackViewController]; } diff --git a/SiriIntents/IntentHandler.m b/SiriIntents/IntentHandler.m index 3a657cb69..9d32a284b 100644 --- a/SiriIntents/IntentHandler.m +++ b/SiriIntents/IntentHandler.m @@ -330,7 +330,7 @@ if (userRoomSummaries) [userRoomSummaries addObject:summary]; else - roomSummaries[diretUserId] = [NSMutableArray arrayWithObject:summary]; + roomSummaries[diretUserId] = [@[summary] mutableCopy]; } }