---
title: SecKeychainSearchCopyNext
framework: security
role: symbol
role_heading: Function
path: security/seckeychainsearchcopynext
---

# SecKeychainSearchCopyNext

Finds the next keychain item matching the given search criteria.

## Declaration

```occ
OSStatus SecKeychainSearchCopyNext(SecKeychainSearchRef searchRef, SecKeychainItemRef*itemRef);
```

## Parameters

- `searchRef`: A reference to the current search criteria. The search object is created in the doc://com.apple.security/documentation/Security/SecKeychainSearchCreateFromAttributes function and must be released by calling the CFRelease function when you are done with it.
- `itemRef`: On return, a pointer to a keychain item object of the next matching keychain item, if any. In Objective-C, call the doc://com.apple.documentation/documentation/CoreFoundation/CFRelease function to release this object when you are finished using it.

## Return Value

Return Value A result code. See Security Framework Result Codes.

## Discussion

Discussion important: This function is deprecated. The common security services manager module is no longer used. Each item stored in the keychain contains data (such as a certificate), which is indexed by the item’s attributes. Use the SecKeychainSearchCreateFromAttributes function to specify attributes to search for. If the SecKeychainSearchCopyNext function finds a match, you can use the SecKeychainItemCopyAttributesAndData(_:_:_:_:_:_:) function to retrieve the item’s data. A SecKeychainItem object for a certificate that is stored in a keychain can be safely cast to a SecCertificate for use with the Certificate, Key, and Trust API. To find and obtain data from a password keychain item, use the SecKeychainFindInternetPassword(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:) or SecKeychainFindGenericPassword(_:_:_:_:_:_:_:_:) function.
