---
title: "init(item:attachedTo:)"
framework: uikit
role: symbol
role_heading: Initializer
path: "uikit/uiattachmentbehavior/init(item:attachedto:)"
---

# init(item:attachedTo:)

Initializes a behavior where the centers of two dynamic items are attached to each other.

## Declaration

```swift
convenience init(item item1: any UIDynamicItem, attachedTo item2: any UIDynamicItem)
```

## Parameters

- `item1`: The first of two dynamic items connected by the attachment behavior.
- `item2`: The second of two dynamic items connected by the attachment behavior.

## Return Value

Return Value The initialized attachment behavior, or nil if there was a problem initializing the object

## Discussion

Discussion The behavior created by this method acts like a solid rod connecting the two items at their center points. Forces applied to one item push or pull the other item accordingly. The items are free to rotate around each other but always remain the same distance apart. The attachment object returned by this method is of type UIAttachmentBehavior.AttachmentType.items.

## See Also

### Creating and initializing attachment behavior objects

- [slidingAttachment(with:attachmentAnchor:axisOfTranslation:)](uikit/uiattachmentbehavior/slidingattachment(with:attachmentanchor:axisoftranslation:).md)
- [slidingAttachment(with:attachedTo:attachmentAnchor:axisOfTranslation:)](uikit/uiattachmentbehavior/slidingattachment(with:attachedto:attachmentanchor:axisoftranslation:).md)
- [fixedAttachment(with:attachedTo:attachmentAnchor:)](uikit/uiattachmentbehavior/fixedattachment(with:attachedto:attachmentanchor:).md)
- [limitAttachment(with:offsetFromCenter:attachedTo:offsetFromCenter:)](uikit/uiattachmentbehavior/limitattachment(with:offsetfromcenter:attachedto:offsetfromcenter:).md)
- [pinAttachment(with:attachedTo:attachmentAnchor:)](uikit/uiattachmentbehavior/pinattachment(with:attachedto:attachmentanchor:).md)
- [init(item:attachedToAnchor:)](uikit/uiattachmentbehavior/init(item:attachedtoanchor:).md)
- [init(item:offsetFromCenter:attachedToAnchor:)](uikit/uiattachmentbehavior/init(item:offsetfromcenter:attachedtoanchor:).md)
- [init(item:offsetFromCenter:attachedTo:offsetFromCenter:)](uikit/uiattachmentbehavior/init(item:offsetfromcenter:attachedto:offsetfromcenter:).md)
