diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index 0b5e24caaa44c7..0ba6deb48e73e3 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -114,8 +114,8 @@ @interface MTRDeviceControllerDelegateInfo : NSObject - (instancetype)initWithDelegate:(id)delegate queue:(dispatch_queue_t)queue; -@property(nonatomic, weak, readonly) id delegate; -@property(nonatomic, readonly) dispatch_queue_t queue; +@property (nonatomic, weak, readonly) id delegate; +@property (nonatomic, readonly) dispatch_queue_t queue; @end @implementation MTRDeviceControllerDelegateInfo @@ -161,7 +161,7 @@ @implementation MTRDeviceController { BOOL _shutdownPending; os_unfair_lock _assertionLock; - NSMutableSet *_delegates; + NSMutableSet * _delegates; id _strongDelegateForSetDelegateAPI; } @@ -599,7 +599,7 @@ - (void)cleanup if (_deviceControllerDelegateBridge) { delete _deviceControllerDelegateBridge; _deviceControllerDelegateBridge = nullptr; - @synchronized (self) { + @synchronized(self) { _strongDelegateForSetDelegateAPI = nil; [_delegates removeAllObjects]; } @@ -1783,7 +1783,7 @@ + (void)forceLocalhostAdvertisingOnly // Note these are implemented in the base class so that XPC subclass can use it as well when it - (void)setDeviceControllerDelegate:(id)delegate queue:(dispatch_queue_t)queue { - @synchronized (self) { + @synchronized(self) { _strongDelegateForSetDelegateAPI = delegate; [self addDeviceControllerDelegate:delegate queue:queue]; } @@ -1791,8 +1791,8 @@ - (void)setDeviceControllerDelegate:(id)delegate qu - (void)addDeviceControllerDelegate:(id)delegate queue:(dispatch_queue_t)queue { - @synchronized (self) { - MTRDeviceControllerDelegateInfo *newDelegateInfo = [[MTRDeviceControllerDelegateInfo alloc] initWithDelegate:delegate queue:queue]; + @synchronized(self) { + MTRDeviceControllerDelegateInfo * newDelegateInfo = [[MTRDeviceControllerDelegateInfo alloc] initWithDelegate:delegate queue:queue]; [_delegates addObject:newDelegateInfo]; MTR_LOG("%@ addDeviceControllerDelegate: added %p total %lu", self, delegate, static_cast(_delegates.count)); } @@ -1800,9 +1800,9 @@ - (void)addDeviceControllerDelegate:(id)delegate qu - (void)removeDeviceControllerDelegate:(id)delegate { - @synchronized (self) { - __block MTRDeviceControllerDelegateInfo *delegateInfoToRemove = nil; - [self _iterateDelegateInfoWithBlock:^(MTRDeviceControllerDelegateInfo *delegateInfo) { + @synchronized(self) { + __block MTRDeviceControllerDelegateInfo * delegateInfoToRemove = nil; + [self _iterateDelegateInfoWithBlock:^(MTRDeviceControllerDelegateInfo * delegateInfo) { if (delegateInfo.delegate == delegate) { delegateInfoToRemove = delegateInfo; } @@ -1822,17 +1822,17 @@ - (void)removeDeviceControllerDelegate:(id)delegate // Iterates the delegates, and remove delegate info objects if the delegate object has dealloc'ed // Returns number of delegates called -- (NSUInteger)_iterateDelegateInfoWithBlock:(void(^ _Nullable)(MTRDeviceControllerDelegateInfo * delegateInfo))block +- (NSUInteger)_iterateDelegateInfoWithBlock:(void (^_Nullable)(MTRDeviceControllerDelegateInfo * delegateInfo))block { - @synchronized (self) { + @synchronized(self) { if (!_delegates.count) { MTR_LOG("%@ No delegates to iterate", self); return 0; } // Opportunistically remove defunct delegate references on every iteration - NSMutableSet *delegatesToRemove = nil; - for (MTRDeviceControllerDelegateInfo *delegateInfo in _delegates) { + NSMutableSet * delegatesToRemove = nil; + for (MTRDeviceControllerDelegateInfo * delegateInfo in _delegates) { id strongDelegate = delegateInfo.delegate; if (strongDelegate) { if (block) { @@ -1855,9 +1855,9 @@ - (NSUInteger)_iterateDelegateInfoWithBlock:(void(^ _Nullable)(MTRDeviceControll } } -- (void)_callDelegatesWithBlock:(void(^ _Nullable)(id delegate))block logString:(const char *)logString; +- (void)_callDelegatesWithBlock:(void (^_Nullable)(id delegate))block logString:(const char *)logString; { - NSUInteger delegatesCalled = [self _iterateDelegateInfoWithBlock:^(MTRDeviceControllerDelegateInfo *delegateInfo) { + NSUInteger delegatesCalled = [self _iterateDelegateInfoWithBlock:^(MTRDeviceControllerDelegateInfo * delegateInfo) { id strongDelegate = delegateInfo.delegate; dispatch_async(delegateInfo.queue, ^{ block(strongDelegate); @@ -1886,9 +1886,9 @@ - (void)controller:(MTRDeviceController *)controller commissioningSessionEstabli } - (void)controller:(MTRDeviceController *)controller -commissioningComplete:(NSError * _Nullable)error - nodeID:(NSNumber * _Nullable)nodeID - metrics:(MTRMetrics *)metrics + commissioningComplete:(NSError * _Nullable)error + nodeID:(NSNumber * _Nullable)nodeID + metrics:(MTRMetrics *)metrics { [self _callDelegatesWithBlock:^(id delegate) { if ([delegate respondsToSelector:@selector(controller:commissioningComplete:nodeID:metrics:)]) {