From 6a1e42a562d0a87178ecd71b285ef4d0ccbd7b8e Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 15 Jan 2016 16:56:16 +0100 Subject: [PATCH] misc: replace [NSNotificationCenter defaultCenter] with NSNotificationCenter.defaultCenter --- Classes/AssistantView.m | 26 ++---- Classes/CallIncomingView.m | 10 +-- Classes/CallOutgoingView.m | 8 +- Classes/CallView.m | 28 +++---- Classes/ChatConversationView.m | 62 +++++++------- Classes/ChatsListTableView.m | 4 +- Classes/ChatsListView.m | 10 +-- Classes/DialerView.m | 20 ++--- Classes/FirstLoginView.m | 10 +-- Classes/HistoryDetailsView.m | 18 ++-- Classes/HistoryListTableView.m | 20 ++--- Classes/HistoryListView.m | 2 +- Classes/InAppProductsManager.m | 4 +- Classes/LinphoneAppDelegate.m | 12 +-- Classes/LinphoneCoreSettingsStore.m | 4 +- Classes/LinphoneManager.m | 97 +++++++++++----------- Classes/LinphoneUI/StatusBarView.m | 50 +++++------ Classes/LinphoneUI/TabBarView.m | 26 +++--- Classes/LinphoneUI/UIBackToCallButton.m | 10 +-- Classes/LinphoneUI/UIBouncingView.m | 18 ++-- Classes/LinphoneUI/UIChatBubblePhotoCell.m | 20 ++--- Classes/LinphoneUI/UICompositeView.m | 12 +-- Classes/LinphoneUI/UIPauseButton.m | 4 +- Classes/LinphoneUI/UIRoundedImageView.m | 10 +-- Classes/PhoneMainView.m | 53 +++++------- Classes/SettingsView.m | 15 ++-- Classes/SideMenuView.m | 8 +- Classes/Utils/FastAddressBook.m | 2 +- Classes/Utils/FileTransferDelegate.m | 10 +-- 29 files changed, 277 insertions(+), 296 deletions(-) diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index 75a726982..df31e2a01 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -84,17 +84,14 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(registrationUpdateEvent:) - name:kLinphoneRegistrationUpdate - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(configuringUpdate:) - name:kLinphoneConfiguringStateUpdate - object:nil]; - // we will set the new default proxy config in the assistant - previous_default_config = linphone_core_get_default_proxy_config([LinphoneManager getLc]); - linphone_core_set_default_proxy_config([LinphoneManager getLc], NULL); + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(registrationUpdateEvent:) + name:kLinphoneRegistrationUpdate + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(configuringUpdate:) + name:kLinphoneConfiguringStateUpdate + object:nil]; new_config = NULL; [self resetTextFields]; @@ -103,12 +100,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - [[NSNotificationCenter defaultCenter] removeObserver:self]; - - // if we quit assistant without creating a new proxy config, just restore the previous one - if (!linphone_core_get_default_proxy_config([LinphoneManager getLc])) { - linphone_core_set_default_proxy_config([LinphoneManager getLc], previous_default_config); - } + [NSNotificationCenter.defaultCenter removeObserver:self]; } - (void)fitContent { diff --git a/Classes/CallIncomingView.m b/Classes/CallIncomingView.m index ec431a6d0..6d8d29b8d 100644 --- a/Classes/CallIncomingView.m +++ b/Classes/CallIncomingView.m @@ -30,16 +30,16 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(callUpdateEvent:) - name:kLinphoneCallUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(callUpdateEvent:) + name:kLinphoneCallUpdate + object:nil]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneCallUpdate object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneCallUpdate object:nil]; } #pragma mark - UICompositeViewDelegate Functions diff --git a/Classes/CallOutgoingView.m b/Classes/CallOutgoingView.m index 420b4cdea..e167cc01c 100644 --- a/Classes/CallOutgoingView.m +++ b/Classes/CallOutgoingView.m @@ -48,10 +48,10 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(bluetoothAvailabilityUpdateEvent:) - name:kLinphoneBluetoothAvailabilityUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(bluetoothAvailabilityUpdateEvent:) + name:kLinphoneBluetoothAvailabilityUpdate + object:nil]; LinphoneCall *call = linphone_core_get_current_call([LinphoneManager getLc]); if (!call) { diff --git a/Classes/CallView.m b/Classes/CallView.m index d613473f9..1f9694af8 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -123,7 +123,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewDidUnload { [PhoneMainView.instance.view removeGestureRecognizer:singleFingerTap]; // Remove all observer - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; [super viewDidUnload]; } @@ -150,18 +150,18 @@ static UICompositeViewDescription *compositeDescription = nil; // Enable tap [singleFingerTap setEnabled:TRUE]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(messageReceived:) - name:kLinphoneMessageReceived - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(bluetoothAvailabilityUpdateEvent:) - name:kLinphoneBluetoothAvailabilityUpdate - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(callUpdateEvent:) - name:kLinphoneCallUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(messageReceived:) + name:kLinphoneMessageReceived + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(bluetoothAvailabilityUpdateEvent:) + name:kLinphoneBluetoothAvailabilityUpdate + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(callUpdateEvent:) + name:kLinphoneCallUpdate + object:nil]; [NSTimer scheduledTimerWithTimeInterval:1 target:self @@ -202,7 +202,7 @@ static UICompositeViewDescription *compositeDescription = nil; } // Remove observer - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } - (void)viewDidDisappear:(BOOL)animated { diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 20a7fc1cd..933508926 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -42,7 +42,7 @@ } - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } #pragma mark - UICompositeViewDelegate Functions @@ -88,34 +88,34 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(applicationWillEnterForeground:) - name:UIApplicationDidBecomeActiveNotification - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(keyboardWillShow:) - name:UIKeyboardWillShowNotification - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(keyboardWillHide:) - name:UIKeyboardWillHideNotification - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(textReceivedEvent:) - name:kLinphoneMessageReceived - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onMessageChange:) - name:UITextViewTextDidChangeNotification - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(textComposeEvent:) - name:kLinphoneTextComposeEvent - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(callUpdateEvent:) - name:kLinphoneCallUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(applicationWillEnterForeground:) + name:UIApplicationDidBecomeActiveNotification + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(keyboardWillShow:) + name:UIKeyboardWillShowNotification + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(keyboardWillHide:) + name:UIKeyboardWillHideNotification + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(textReceivedEvent:) + name:kLinphoneMessageReceived + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(onMessageChange:) + name:UITextViewTextDidChangeNotification + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(textComposeEvent:) + name:kLinphoneTextComposeEvent + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(callUpdateEvent:) + name:kLinphoneCallUpdate + object:nil]; [_backToCallButton update]; @@ -137,7 +137,7 @@ static UICompositeViewDescription *compositeDescription = nil; [self setComposingVisible:FALSE withDelay:0]; // will hide the "user is composing.." message - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { @@ -331,7 +331,7 @@ static UICompositeViewDescription *compositeDescription = nil; if (strcasecmp(cr_from_string, fromStr) == 0) { if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { linphone_chat_room_mark_as_read(room); - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneMessageReceived object:self]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:self]; } [_tableController addChatEntry:chat]; [_tableController scrollToLastUnread:TRUE]; diff --git a/Classes/ChatsListTableView.m b/Classes/ChatsListTableView.m index ddb4ed335..8ed558546 100644 --- a/Classes/ChatsListTableView.m +++ b/Classes/ChatsListTableView.m @@ -193,7 +193,7 @@ static void chatTable_free_chatrooms(void *data) { data = ms_list_remove(data, chatRoom); // will force a call to [self loadData] - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneMessageReceived object:self]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:self]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; @@ -223,7 +223,7 @@ static void chatTable_free_chatrooms(void *data) { data = ms_list_remove(data, chatRoom); // will force a call to [self loadData] - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneMessageReceived object:self]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:self]; }]; } diff --git a/Classes/ChatsListView.m b/Classes/ChatsListView.m index 6fe1e2c28..6f7798769 100644 --- a/Classes/ChatsListView.m +++ b/Classes/ChatsListView.m @@ -27,10 +27,10 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(textReceivedEvent:) - name:kLinphoneMessageReceived - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(textReceivedEvent:) + name:kLinphoneMessageReceived + object:nil]; [_backToCallButton update]; [self setEditing:NO]; } @@ -38,7 +38,7 @@ - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneMessageReceived object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneMessageReceived object:nil]; } #pragma mark - Event Functions diff --git a/Classes/DialerView.m b/Classes/DialerView.m index d6a3538dc..bf96f1f38 100644 --- a/Classes/DialerView.m +++ b/Classes/DialerView.m @@ -64,7 +64,7 @@ - (void)dealloc { // Remove all observers - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } #pragma mark - UICompositeViewDelegate Functions @@ -98,15 +98,15 @@ static UICompositeViewDescription *compositeDescription = nil; !IPAD && UIInterfaceOrientationIsLandscape(PhoneMainView.instance.mainViewController.currentOrientation); // Set observer - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(callUpdateEvent:) - name:kLinphoneCallUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(callUpdateEvent:) + name:kLinphoneCallUpdate + object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(coreUpdateEvent:) - name:kLinphoneCoreUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(coreUpdateEvent:) + name:kLinphoneCoreUpdate + object:nil]; // technically not needed, but older versions of linphone had this button // disabled by default. In this case, updating by pushing a new version with @@ -146,7 +146,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } - (void)viewDidLoad { diff --git a/Classes/FirstLoginView.m b/Classes/FirstLoginView.m index cd2473341..a0dd66fb7 100644 --- a/Classes/FirstLoginView.m +++ b/Classes/FirstLoginView.m @@ -51,10 +51,10 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // Set observer - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(registrationUpdateEvent:) - name:kLinphoneRegistrationUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(registrationUpdateEvent:) + name:kLinphoneRegistrationUpdate + object:nil]; [_usernameField setText:[[LinphoneManager instance] lpConfigStringForKey:@"assistant_username"]]; [_passwordField setText:[[LinphoneManager instance] lpConfigStringForKey:@"assistant_password"]]; @@ -97,7 +97,7 @@ static UICompositeViewDescription *compositeDescription = nil; [super viewWillDisappear:animated]; // Remove observer - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneRegistrationUpdate object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneRegistrationUpdate object:nil]; } - (void)viewDidLoad { diff --git a/Classes/HistoryDetailsView.m b/Classes/HistoryDetailsView.m index 02216d51c..ca8f5468f 100644 --- a/Classes/HistoryDetailsView.m +++ b/Classes/HistoryDetailsView.m @@ -72,20 +72,20 @@ static UICompositeViewDescription *compositeDescription = nil; [self update]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(update) - name:kLinphoneAddressBookUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(update) + name:kLinphoneAddressBookUpdate + object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(coreUpdateEvent:) - name:kLinphoneCoreUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(coreUpdateEvent:) + name:kLinphoneCoreUpdate + object:nil]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } #pragma mark - Event Functions diff --git a/Classes/HistoryListTableView.m b/Classes/HistoryListTableView.m index d65cd98d1..807d4fa35 100644 --- a/Classes/HistoryListTableView.m +++ b/Classes/HistoryListTableView.m @@ -53,24 +53,24 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(loadData) - name:kLinphoneAddressBookUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(loadData) + name:kLinphoneAddressBookUpdate + object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(coreUpdateEvent:) - name:kLinphoneCoreUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(coreUpdateEvent:) + name:kLinphoneCoreUpdate + object:nil]; [self loadData]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneAddressBookUpdate object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneAddressBookUpdate object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneCoreUpdate object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneCoreUpdate object:nil]; } #pragma mark - Event Functions diff --git a/Classes/HistoryListView.m b/Classes/HistoryListView.m index fa9c6be73..72fd365ca 100644 --- a/Classes/HistoryListView.m +++ b/Classes/HistoryListView.m @@ -60,7 +60,7 @@ static UICompositeViewDescription *compositeDescription = nil; // Reset missed call linphone_core_reset_missed_calls_count([LinphoneManager getLc]); // Fake event - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneCallUpdate object:self]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneCallUpdate object:self]; } #pragma mark - diff --git a/Classes/InAppProductsManager.m b/Classes/InAppProductsManager.m index 76cb06fca..44e04d504 100644 --- a/Classes/InAppProductsManager.m +++ b/Classes/InAppProductsManager.m @@ -374,7 +374,7 @@ - (void)postNotificationforStatus:(IAPPurchaseNotificationStatus)status withDict:(NSDictionary *)dict { _status = status; LOGI(@"Triggering notification for status %@", status); - [[NSNotificationCenter defaultCenter] postNotificationName:status object:self userInfo:dict]; + [NSNotificationCenter.defaultCenter postNotificationName:status object:self userInfo:dict]; } - (void)XMLRPCRequest:(XMLRPCRequest *)request didReceiveResponse:(XMLRPCResponse *)response { @@ -479,7 +479,7 @@ #else - (void)postNotificationforStatus:(IAPPurchaseNotificationStatus)status { _status = status; - [[NSNotificationCenter defaultCenter] postNotificationName:status object:self userInfo:nil]; + [NSNotificationCenter.defaultCenter postNotificationName:status object:self userInfo:nil]; LOGE(@"Not supported, triggering %@", status); } - (BOOL)purchaseAccount:(NSString *)phoneNumber diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index c55dd4db4..9e2d3e3b1 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -455,7 +455,7 @@ - (void)ConfigurationStateUpdateEvent:(NSNotification *)notif { LinphoneConfiguringState state = [[notif.userInfo objectForKey:@"state"] intValue]; if (state == LinphoneConfiguringSuccessful) { - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneConfiguringStateUpdate object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneConfiguringStateUpdate object:nil]; [_waitingIndicator dismissWithClickedButtonIndex:0 animated:true]; UIAlertView *error = [[UIAlertView alloc] @@ -468,7 +468,7 @@ [PhoneMainView.instance startUp]; } if (state == LinphoneConfiguringFailed) { - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneConfiguringStateUpdate object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneConfiguringStateUpdate object:nil]; [_waitingIndicator dismissWithClickedButtonIndex:0 animated:true]; UIAlertView *error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Failure", nil) @@ -507,10 +507,10 @@ - (void)attemptRemoteConfiguration { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(ConfigurationStateUpdateEvent:) - name:kLinphoneConfiguringStateUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(ConfigurationStateUpdateEvent:) + name:kLinphoneConfiguringStateUpdate + object:nil]; linphone_core_set_provisioning_uri([LinphoneManager getLc], [configURL UTF8String]); [[LinphoneManager instance] destroyLinphoneCore]; [[LinphoneManager instance] startLinphoneCore]; diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 820adb1a9..c6a9269f3 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -385,7 +385,7 @@ // Post event NSDictionary *eventDic = [NSDictionary dictionaryWithObject:self forKey:@"settings"]; - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneLogsUpdate object:self userInfo:eventDic]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneLogsUpdate object:self userInfo:eventDic]; } - (void)alertAccountError:(NSString *)error { @@ -835,7 +835,7 @@ // Post event NSDictionary *eventDic = [NSDictionary dictionaryWithObject:self forKey:@"settings"]; - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneSettingsUpdate object:self userInfo:eventDic]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneSettingsUpdate object:self userInfo:eventDic]; return YES; } diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index ea7343d3c..2034050bd 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -251,10 +251,10 @@ struct codec_name_pref_table codec_pref_table[] = {{"speex", 8000, "speex_8k_pre - (id)init { if ((self = [super init])) { AudioSessionInitialize(NULL, NULL, NULL, NULL); - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(audioRouteChangeListenerCallback2:) - name:AVAudioSessionRouteChangeNotification - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(audioRouteChangeListenerCallback2:) + name:AVAudioSessionRouteChangeNotification + object:nil]; NSString *path = [[NSBundle mainBundle] pathForResource:@"msg" ofType:@"wav"]; self.messagePlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:path] error:nil]; @@ -292,7 +292,7 @@ struct codec_name_pref_table codec_pref_table[] = {{"speex", 8000, "speex_8k_pre } - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } - (void)silentPushFailed:(NSTimer *)timer { @@ -585,11 +585,11 @@ static void linphone_iphone_log_user_warning(struct _LinphoneCore *lc, const cha - (void)displayStatus:(NSString *)message { // Post event - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneDisplayStatusUpdate - object:self - userInfo:@{ - @"message" : message - }]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneDisplayStatusUpdate + object:self + userInfo:@{ + @"message" : message + }]; } static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char *message) { @@ -773,8 +773,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char @"state" : [NSNumber numberWithInt:state], @"message" : [NSString stringWithUTF8String:message] }; - LOGI(@"Call %p changed to state %s: %s", call, linphone_call_state_to_string(state), message); - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneCallUpdate object:self userInfo:dict]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneCallUpdate object:self userInfo:dict]; } static void linphone_iphone_call_state(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState state, @@ -802,7 +801,7 @@ static void linphone_iphone_global_state_changed(LinphoneCore *lc, LinphoneGloba // dispatch the notification asynchronously dispatch_async(dispatch_get_main_queue(), ^(void) { - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneGlobalStateUpdate object:self userInfo:dict]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneGlobalStateUpdate object:self userInfo:dict]; }); } @@ -829,9 +828,9 @@ static void linphone_iphone_configuring_status_changed(LinphoneCore *lc, Linphon // dispatch the notification asynchronously dispatch_async(dispatch_get_main_queue(), ^(void) { - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneConfiguringStateUpdate - object:self - userInfo:dict]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneConfiguringStateUpdate + object:self + userInfo:dict]; }); } @@ -856,7 +855,7 @@ static void linphone_iphone_configuring_status_changed(LinphoneCore *lc, Linphon NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:state], @"state", [NSValue valueWithPointer:cfg], @"cfg", [NSString stringWithUTF8String:message], @"message", nil]; - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneRegistrationUpdate object:self userInfo:dict]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneRegistrationUpdate object:self userInfo:dict]; } static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyConfig *cfg, @@ -966,7 +965,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char @"call-id" : callID }; - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneMessageReceived object:self userInfo:dict]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:self userInfo:dict]; } static void linphone_iphone_message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message) { @@ -984,7 +983,7 @@ static void linphone_iphone_message_received(LinphoneCore *lc, LinphoneChatRoom if (body != NULL) { [dict setObject:[NSValue valueWithPointer:body] forKey:@"content"]; } - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneNotifyReceived object:self userInfo:dict]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneNotifyReceived object:self userInfo:dict]; } static void linphone_iphone_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *notified_event, @@ -1012,19 +1011,17 @@ static void linphone_iphone_call_encryption_changed(LinphoneCore *lc, LinphoneCa [dict setObject:[NSValue valueWithPointer:call] forKey:@"call"]; [dict setObject:[NSNumber numberWithBool:on] forKey:@"on"]; [dict setObject:[NSString stringWithUTF8String:authentication_token] forKey:@"token"]; - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneCallEncryptionChanged - object:self - userInfo:dict]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneCallEncryptionChanged object:self userInfo:dict]; } #pragma mark - Message composition start - (void)onMessageComposeReceived:(LinphoneCore *)core forRoom:(LinphoneChatRoom *)room { - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneTextComposeEvent - object:self - userInfo:@{ - @"room" : [NSValue valueWithPointer:room] - }]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneTextComposeEvent + object:self + userInfo:@{ + @"room" : [NSValue valueWithPointer:room] + }]; } static void linphone_iphone_is_composing_received(LinphoneCore *lc, LinphoneChatRoom *room) { @@ -1388,9 +1385,9 @@ static LinphoneCoreVTable linphonec_vtable = { // Post event NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSValue valueWithPointer:theLinphoneCore] forKey:@"core"]; - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneCoreUpdate - object:[LinphoneManager instance] - userInfo:dict]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneCoreUpdate + object:[LinphoneManager instance] + userInfo:dict]; } static BOOL libStarted = FALSE; @@ -1493,19 +1490,19 @@ static BOOL libStarted = FALSE; (or skipped). Wait for this to finish the code configuration */ - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(audioSessionInterrupted:) - name:AVAudioSessionInterruptionNotification - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(globalStateChangedNotificationHandler:) - name:kLinphoneGlobalStateUpdate - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(configuringStateChangedNotificationHandler:) - name:kLinphoneConfiguringStateUpdate - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(inappReady:) name:kIAPReady object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(audioSessionInterrupted:) + name:AVAudioSessionInterruptionNotification + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(globalStateChangedNotificationHandler:) + name:kLinphoneGlobalStateUpdate + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(configuringStateChangedNotificationHandler:) + name:kLinphoneConfiguringStateUpdate + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(inappReady:) name:kIAPReady object:nil]; /*call iterate once immediately in order to initiate background connections with sip server or remote provisioning * grab, if any */ @@ -1520,7 +1517,7 @@ static BOOL libStarted = FALSE; // just in case [self removeCTCallCenterCb]; - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; if (theLinphoneCore != nil) { // just in case application terminate before linphone core initialization @@ -1537,9 +1534,9 @@ static BOOL libStarted = FALSE; // Post event NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSValue valueWithPointer:theLinphoneCore] forKey:@"core"]; - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneCoreUpdate - object:[LinphoneManager instance] - userInfo:dict]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneCoreUpdate + object:[LinphoneManager instance] + userInfo:dict]; SCNetworkReachabilityUnscheduleFromRunLoop(proxyReachability, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); if (proxyReachability) @@ -1841,9 +1838,9 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { } NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:bluetoothAvailable], @"available", nil]; - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneBluetoothAvailabilityUpdate - object:self - userInfo:dict]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneBluetoothAvailabilityUpdate + object:self + userInfo:dict]; CFRelease(newRoute); } } diff --git a/Classes/LinphoneUI/StatusBarView.m b/Classes/LinphoneUI/StatusBarView.m index 1e0b19cdc..6457645a0 100644 --- a/Classes/LinphoneUI/StatusBarView.m +++ b/Classes/LinphoneUI/StatusBarView.m @@ -31,7 +31,7 @@ #pragma mark - Lifecycle Functions - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; [callQualityTimer invalidate]; } @@ -41,29 +41,29 @@ [super viewWillAppear:animated]; // Set observer - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(registrationUpdate:) - name:kLinphoneRegistrationUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(registrationUpdate:) + name:kLinphoneRegistrationUpdate + object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(globalStateUpdate:) - name:kLinphoneGlobalStateUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(globalStateUpdate:) + name:kLinphoneGlobalStateUpdate + object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(notifyReceived:) - name:kLinphoneNotifyReceived - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(notifyReceived:) + name:kLinphoneNotifyReceived + object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(callUpdate:) - name:kLinphoneCallUpdate - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onCallEncryptionChanged:) - name:kLinphoneCallEncryptionChanged - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(callUpdate:) + name:kLinphoneCallUpdate + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(onCallEncryptionChanged:) + name:kLinphoneCallEncryptionChanged + object:nil]; // Update to default state LinphoneProxyConfig *config = linphone_core_get_default_proxy_config([LinphoneManager getLc]); @@ -79,10 +79,10 @@ [super viewWillDisappear:animated]; // Remove observer - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneRegistrationUpdate object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneGlobalStateUpdate object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneNotifyReceived object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneCallUpdate object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneRegistrationUpdate object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneGlobalStateUpdate object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneNotifyReceived object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneCallUpdate object:nil]; if (callQualityTimer != nil) { [callQualityTimer invalidate]; diff --git a/Classes/LinphoneUI/TabBarView.m b/Classes/LinphoneUI/TabBarView.m index ed3c10e1b..af0c6fbc8 100644 --- a/Classes/LinphoneUI/TabBarView.m +++ b/Classes/LinphoneUI/TabBarView.m @@ -27,24 +27,24 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(changeViewEvent:) - name:kLinphoneMainViewChange - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(callUpdate:) - name:kLinphoneCallUpdate - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(messageReceived:) - name:kLinphoneMessageReceived - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(changeViewEvent:) + name:kLinphoneMainViewChange + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(callUpdate:) + name:kLinphoneCallUpdate + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(messageReceived:) + name:kLinphoneMessageReceived + object:nil]; [self update:FALSE]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { diff --git a/Classes/LinphoneUI/UIBackToCallButton.m b/Classes/LinphoneUI/UIBackToCallButton.m index 377e1ea57..20e25fabc 100644 --- a/Classes/LinphoneUI/UIBackToCallButton.m +++ b/Classes/LinphoneUI/UIBackToCallButton.m @@ -14,16 +14,16 @@ - (instancetype)init { if (self = [super init]) { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(callUpdateEvent:) - name:kLinphoneCallUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(callUpdateEvent:) + name:kLinphoneCallUpdate + object:nil]; } return self; } - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } - (void)callUpdateEvent:(NSNotification *)notif { diff --git a/Classes/LinphoneUI/UIBouncingView.m b/Classes/LinphoneUI/UIBouncingView.m index 9a6946596..d43a8f305 100644 --- a/Classes/LinphoneUI/UIBouncingView.m +++ b/Classes/LinphoneUI/UIBouncingView.m @@ -18,19 +18,19 @@ static NSString *const kDisappearAnimation = @"disappear"; @implementation UIBouncingView INIT_WITH_COMMON_CF { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(settingsUpdate:) - name:kLinphoneSettingsUpdate - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(applicationWillEnterForeground:) - name:UIApplicationWillEnterForegroundNotification - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(settingsUpdate:) + name:kLinphoneSettingsUpdate + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(applicationWillEnterForeground:) + name:UIApplicationWillEnterForegroundNotification + object:nil]; return self; } - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } - (void)settingsUpdate:(NSNotification *)notif { diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.m b/Classes/LinphoneUI/UIChatBubblePhotoCell.m index a1b3bd068..01675d019 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.m +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.m @@ -210,19 +210,19 @@ _ftd = aftd; _fileTransferProgress.progress = 0; - [[NSNotificationCenter defaultCenter] removeObserver:self]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onFileTransferSendUpdate:) - name:kLinphoneFileTransferSendUpdate - object:_ftd]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onFileTransferRecvUpdate:) - name:kLinphoneFileTransferRecvUpdate - object:_ftd]; + [NSNotificationCenter.defaultCenter removeObserver:self]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(onFileTransferSendUpdate:) + name:kLinphoneFileTransferSendUpdate + object:_ftd]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(onFileTransferRecvUpdate:) + name:kLinphoneFileTransferRecvUpdate + object:_ftd]; } - (void)disconnectFromFileDelegate { - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; _ftd = nil; } diff --git a/Classes/LinphoneUI/UICompositeView.m b/Classes/LinphoneUI/UICompositeView.m index 470eff907..d17a94655 100644 --- a/Classes/LinphoneUI/UICompositeView.m +++ b/Classes/LinphoneUI/UICompositeView.m @@ -116,7 +116,7 @@ } - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } #pragma mark - ViewController Functions @@ -158,10 +158,10 @@ [self.tabBarViewController viewWillAppear:animated]; [self.statusBarViewController viewWillAppear:animated]; [self.sideMenuViewController viewWillAppear:animated]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(orientationDidChange:) - name:UIDeviceOrientationDidChangeNotification - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(orientationDidChange:) + name:UIDeviceOrientationDidChangeNotification + object:nil]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; } @@ -184,7 +184,7 @@ [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; } - (void)viewDidDisappear:(BOOL)animated { diff --git a/Classes/LinphoneUI/UIPauseButton.m b/Classes/LinphoneUI/UIPauseButton.m index 586de121d..d10999eab 100644 --- a/Classes/LinphoneUI/UIPauseButton.m +++ b/Classes/LinphoneUI/UIPauseButton.m @@ -106,7 +106,7 @@ linphone_core_leave_conference([LinphoneManager getLc]); // Fake event - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneCallUpdate object:self]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneCallUpdate object:self]; break; } case UIPauseButtonType_CurrentCall: { @@ -134,7 +134,7 @@ case UIPauseButtonType_Conference: { linphone_core_enter_conference([LinphoneManager getLc]); // Fake event - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneCallUpdate object:self]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneCallUpdate object:self]; break; } case UIPauseButtonType_CurrentCall: { diff --git a/Classes/LinphoneUI/UIRoundedImageView.m b/Classes/LinphoneUI/UIRoundedImageView.m index aab2dfe69..2b75d4eee 100644 --- a/Classes/LinphoneUI/UIRoundedImageView.m +++ b/Classes/LinphoneUI/UIRoundedImageView.m @@ -23,15 +23,15 @@ INIT_WITH_COMMON_CF { [self setBordered:NO]; [self setRoundRadius]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(orientationDidChange:) - name:@"UIDeviceOrientationDidChangeNotification" - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(orientationDidChange:) + name:@"UIDeviceOrientationDidChangeNotification" + object:nil]; return self; } - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } - (void)orientationDidChange:(NSNotification *)k { diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index 36897925b..48ec5cb01 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -154,7 +154,7 @@ static RootViewManager *rootViewManagerInstance = nil; } - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } #pragma mark - ViewController Functions @@ -173,39 +173,32 @@ static RootViewManager *rootViewManagerInstance = nil; [super viewWillAppear:animated]; // Set observers - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(callUpdate:) - name:kLinphoneCallUpdate - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(registrationUpdate:) - name:kLinphoneRegistrationUpdate - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(textReceived:) - name:kLinphoneMessageReceived - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onGlobalStateChanged:) - name:kLinphoneGlobalStateUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(callUpdate:) + name:kLinphoneCallUpdate + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(registrationUpdate:) + name:kLinphoneRegistrationUpdate + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(textReceived:) + name:kLinphoneMessageReceived + object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(onGlobalStateChanged:) + name:kLinphoneGlobalStateUpdate + object:nil]; [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(batteryLevelChanged:) - name:UIDeviceBatteryLevelDidChangeNotification - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(batteryLevelChanged:) + name:UIDeviceBatteryLevelDidChangeNotification + object:nil]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - - // Remove observers - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneCallUpdate object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneRegistrationUpdate object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneMessageReceived object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self - name:UIDeviceBatteryLevelDidChangeNotification - object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self]; [[UIDevice currentDevice] setBatteryMonitoringEnabled:NO]; } @@ -591,7 +584,7 @@ static RootViewManager *rootViewManagerInstance = nil; //[[RootViewManager instance] setViewControllerForDescription:view]; NSDictionary *mdict = [NSMutableDictionary dictionaryWithObject:vc->currentView forKey:@"view"]; - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneMainViewChange object:self userInfo:mdict]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMainViewChange object:self userInfo:mdict]; return [vc->mainViewController getCurrentViewController]; } diff --git a/Classes/SettingsView.m b/Classes/SettingsView.m index 9c5d2c9d2..4994f1d52 100644 --- a/Classes/SettingsView.m +++ b/Classes/SettingsView.m @@ -161,7 +161,7 @@ } // Start notification after animation of DCRoundSwitch dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] + [NSNotificationCenter.defaultCenter postNotificationName:kIASKAppSettingChanged object:[toggle key] userInfo:[NSDictionary dictionaryWithObject:[self.settingsStore objectForKey:[toggle key]] @@ -368,7 +368,7 @@ static UICompositeViewDescription *compositeDescription = nil; [super viewWillDisappear:animated]; [_settingsController dismiss:self]; // Set observer - [[NSNotificationCenter defaultCenter] removeObserver:self name:kIASKAppSettingChanged object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kIASKAppSettingChanged object:nil]; if (linphone_ringtoneplayer_is_started(linphone_core_get_ringtoneplayer([LinphoneManager getLc]))) { linphone_core_stop_ringing([LinphoneManager getLc]); @@ -383,10 +383,10 @@ static UICompositeViewDescription *compositeDescription = nil; [self recomputeAccountLabelsAndSync]; // Set observer - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(appSettingChanged:) - name:kIASKAppSettingChanged - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(appSettingChanged:) + name:kIASKAppSettingChanged + object:nil]; } #pragma mark - Event Functions @@ -669,8 +669,7 @@ static UICompositeViewDescription *compositeDescription = nil; } else if ([key isEqual:@"battery_alert_button"]) { [[UIDevice currentDevice] _setBatteryState:UIDeviceBatteryStateUnplugged]; [[UIDevice currentDevice] _setBatteryLevel:0.01f]; - [[NSNotificationCenter defaultCenter] postNotificationName:UIDeviceBatteryLevelDidChangeNotification - object:self]; + [NSNotificationCenter.defaultCenter postNotificationName:UIDeviceBatteryLevelDidChangeNotification object:self]; } else if ([key isEqual:@"flush_images_button"]) { const MSList *rooms = linphone_core_get_chat_rooms([LinphoneManager getLc]); while (rooms) { diff --git a/Classes/SideMenuView.m b/Classes/SideMenuView.m index 8400bd301..bb903046e 100644 --- a/Classes/SideMenuView.m +++ b/Classes/SideMenuView.m @@ -26,10 +26,10 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(registrationUpdateEvent:) - name:kLinphoneRegistrationUpdate - object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(registrationUpdateEvent:) + name:kLinphoneRegistrationUpdate + object:nil]; [self updateHeader]; [_sideMenuTableViewController.tableView reloadData]; diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index 7bc2eae63..d683a7ab4 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -237,7 +237,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info } CFRelease(lContacts); } - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneAddressBookUpdate object:self]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneAddressBookUpdate object:self]; } void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void *context) { diff --git a/Classes/Utils/FileTransferDelegate.m b/Classes/Utils/FileTransferDelegate.m index 3ffef5ae6..81c37856e 100644 --- a/Classes/Utils/FileTransferDelegate.m +++ b/Classes/Utils/FileTransferDelegate.m @@ -75,7 +75,7 @@ static void linphone_iphone_file_transfer_recv(LinphoneChatMessage *message, con inMessage:message]; } thiz.message = NULL; - [[NSNotificationCenter defaultCenter] + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneFileTransferRecvUpdate object:thiz userInfo:@{ @@ -93,7 +93,7 @@ static void linphone_iphone_file_transfer_recv(LinphoneChatMessage *message, con LOGD(@"Transfer of %s (%d bytes): already %ld sent, adding %ld", linphone_content_get_name(content), linphone_content_get_size(content), [thiz.data length], size); [thiz.data appendBytes:linphone_buffer_get_string_content(buffer) length:size]; - [[NSNotificationCenter defaultCenter] + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneFileTransferRecvUpdate object:thiz userInfo:@{ @@ -116,9 +116,9 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m }]; LOGD(@"Transfer of %s (%d bytes): already sent %ld (%f%%), remaining %ld", linphone_content_get_name(content), total, offset, offset * 100.f / total, remaining); - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneFileTransferSendUpdate - object:thiz - userInfo:dict]; + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneFileTransferSendUpdate + object:thiz + userInfo:dict]; LinphoneBuffer *buffer = NULL; @try {