detectedTypes
A property that contains the categories of sensitive content that analysis detects.
Declaration
var detectedTypes: Set<SCSensitivityAnalysis.ContentType> { get }Mentioned in
Discussion
The Sensitive Content Analysis framework sets this property when analysis determines that media contains sensitive content. Check this property to determine the specific types of sensitive content, such as sexuallyExplicit or goreOrViolence. The framework populates this set only when isSensitive is true.
For example, the following code checks for specific content types after determining that media is sensitive:
let analysis = try await analyzer.analyzeImage(at: imageURL)
guard analysis.isSensitive else {
displayContent(imageURL)
return
}
// Check for specific harm types.
let detectedTypes = analysis.detectedTypes
if detectedTypes.contains(.sexuallyExplicit) {
showContentWarning(
message: "This image may contain nudity.",
allowAccess: true
)
}
if detectedTypes.contains(.goreOrViolence) {
blockContent(
message: "This image may contain violence or gore.",
offerResources: true
)
}