<!--
{
  "availability" : [
    "macOS: 10.4.0 - 10.15.0"
  ],
  "documentType" : "symbol",
  "framework" : "Quartz",
  "identifier" : "/documentation/Quartz/QCPlugIn/addInputPort(withType:forKey:withAttributes:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Quartz"
    ],
    "preciseIdentifier" : "c:objc(cs)QCPlugIn(im)addInputPortWithType:forKey:withAttributes:"
  },
  "title" : "addInputPort(withType:forKey:withAttributes:)"
}
-->

# addInputPort(withType:forKey:withAttributes:)

Adds an input port of the specified type and associates a key and attributes with the port.

```
func addInputPort(withType type: String!, forKey key: String!, withAttributes attributes: [AnyHashable : Any]! = [:])
```

## Parameters

`type`

The port type. See [Port Input and Output Types](/documentation/Quartz/port-input-and-output-types).

`key`

The key to associate with the port.

`attributes`

A dictionary of attributes for the port. See [Input and Output Port Attributes](/documentation/Quartz/input-and-output-port-attributes). Although the dictionary is optional, it’s recommended that provide attributes to enhance the experience of those who use your custom patch. The attributes appear in a help tag when the user hovers a pointer over the property port on your custom patch. (See [`attributesForPropertyPort(withKey:)`](/documentation/Quartz/QCPlugIn/attributesForPropertyPort(withKey:)).) Pass  `nil` if you do not want to provide attributes.

## Discussion

This method throws an exception if called from within  the [`execute(_:atTime:withArguments:)`](/documentation/Quartz/QCPlugIn/execute(_:atTime:withArguments:)) method  or if there’s already an input or output port with that key.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)