<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFBagCallBacks/retain",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@SA@CFBagCallBacks@FI@retain"
  },
  "title" : "retain"
}
-->

# retain

The callback used to retain each value as they are added to the collection. If `NULL`, values are not retained. See [`CFBagRetainCallBack`](/documentation/CoreFoundation/CFBagRetainCallBack) for a descriptions of this function’s parameters.

```
var retain: CFBagRetainCallBack!
```

---

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)