---
title: "AXObserverGetRunLoopSource(_:)"
framework: Application Services
role: symbol
role_heading: Function
platforms: [macOS 10.2+]
path: applicationservices/1459139-axobservergetrunloopsource
---

# AXObserverGetRunLoopSource(_:)

Returns the observer's run loop source.

## Declaration

```swift
func AXObserverGetRunLoopSource(_ observer: AXObserver) -> CFRunLoopSource
```

## Parameters

- `observer`: The observer object (created from a call to doc://com.apple.documentation/documentation/applicationservices/1460133-axobservercreate) for which to get the run loop source.

## Return Value

Return Value Returns the CFRunLoopSourceRef of the observer; NIL if you pass NIL in observer.

## Discussion

Discussion The observer must be added to a run loop before it can receive notifications. Note that releasing the AXObserverRef automatically removes the run loop source from the run loop (you can also do this explicitly by calling CFRunLoopRemoveSource(_:_:_:)). AXObserverGetRunLoopSource might be used in code in this way:    CFRunLoopAddSource(CFRunLoopGetCurrent(), AXObserverGetRunLoopSource(observer), kCFRunLoopDefaultMode);

## See Also

### Notification API

- [AXObserverAddNotification(_:_:_:_:)](applicationservices/1462089-axobserveraddnotification.md)
- [AXObserverCreate(_:_:_:)](applicationservices/1460133-axobservercreate.md)
- [AXObserverCreateWithInfoCallback(_:_:_:)](applicationservices/1460610-axobservercreatewithinfocallback.md)
- [AXObserverGetTypeID()](applicationservices/1461244-axobservergettypeid.md)
- [AXObserverRemoveNotification(_:_:_:)](applicationservices/1462066-axobserverremovenotification.md)
