---
title: "servicesWithTypes(_:)"
framework: homekit
role: symbol
role_heading: Instance Method
path: "homekit/hmhome/serviceswithtypes(_:)"
---

# servicesWithTypes(_:)

Returns an array of all services provided by accessories in the home that match the specified types.

## Declaration

```swift
func servicesWithTypes(_ serviceTypes: [String]) -> [HMService]?
```

## Parameters

- `serviceTypes`: An array of strings that identify service types. See doc://com.apple.homekit/documentation/HomeKit/accessory-service-types for a list of types.

## Return Value

Return Value An array of found services. Returns nil if no matching services are found.

## See Also

### Grouping services

- [serviceGroups](homekit/hmhome/servicegroups.md)
- [addServiceGroup(withName:completionHandler:)](homekit/hmhome/addservicegroup(withname:completionhandler:).md)
- [removeServiceGroup(_:completionHandler:)](homekit/hmhome/removeservicegroup(_:completionhandler:).md)
- [HMServiceGroup](homekit/hmservicegroup.md)
