---
title: "messages(of:for:bufferSize:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/notificationcenter/messages(of:for:buffersize:)-623kg"
---

# messages(of:for:bufferSize:)

Returns an asynchronous sequence of messages produced by this center for a given subject and message type.

## Declaration

```swift
func messages<Message>(of subject: Message.Subject? = nil, for messageType: Message.Type, bufferSize limit: Int = 10) -> some Sendable & AsyncSequence<Message, Never> where Message : NotificationCenter.AsyncMessage, Message.Subject : AnyObject

```

## Parameters

- `subject`: The subject to observe. Specify a metatype to observe all values for a given type.
- `messageType`: The message type to be observed.
- `limit`: The maximum number of messages allowed to buffer.

## Return Value

Return Value An asynchronous sequence of messages produced by this center.

## See Also

### Receiving notifications as asynchronous sequences

- [messages(of:for:bufferSize:)](foundation/notificationcenter/messages(of:for:buffersize:)-4tof0.md)
- [messages(of:for:bufferSize:)](foundation/notificationcenter/messages(of:for:buffersize:)-1ub69.md)
