<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ModelIO",
  "identifier" : "/documentation/ModelIO/MDLComponent",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Model I/O"
    ],
    "preciseIdentifier" : "c:objc(pl)MDLComponent"
  },
  "title" : "MDLComponent"
}
-->

# MDLComponent

The base protocol for extensible file format support in Model I/O.

```
protocol MDLComponent : NSObjectProtocol
```

## Overview

By extending this protocol in your own custom protocols, you can define new functionality to add to the [`MDLObject`](/documentation/ModelIO/MDLObject) instances in the object graph corresponding to a [`MDLAsset`](/documentation/ModelIO/MDLAsset) instance.

Model I/O adopts this pattern to support container objects (with the [`MDLObjectContainerComponent`](/documentation/ModelIO/MDLObjectContainerComponent) protocol) and objects with associated transformations (with the [`MDLTransformComponent`](/documentation/ModelIO/MDLTransformComponent) protocol). To work with these aspects of a Model I/O object, call the object’s [`componentConforming(to:)`](/documentation/ModelIO/MDLObject/componentConforming(to:)) method with the appropriate protocol. (The [`MDLObject`](/documentation/ModelIO/MDLObject) class also provides convenience methods and properties for accessing features of these components without directly accessing the component instances.)

To add your own object features, first define a protocol that extends the [`MDLComponent`](/documentation/ModelIO/MDLComponent) protocol, implement a class that adopts that protocol, and then use the [`setComponent(_:for:)`](/documentation/ModelIO/MDLObject/setComponent(_:for:)) method to add your component to each object that needs it. The example below shows how you might implement a file format that associates scripting event triggers with parts of a game scene.

```objc
@protocol MyScriptTriggerComponent <MDLComponent>
// key: trigger identifier, value: scripting-language code
@property NSDictionary<NSString *, NSString *> *scriptTriggers;
@end
 
@interface MyScriptTriggerStorage <MyScriptTriggerComponent>
@property NSDictionary<NSString *, NSString *> *scriptTriggers;
@end
 
@implementation MDLObject (MyScriptTriggers)
- (void)setScriptTriggers:(NSDictionary<NSString *, NSString *>)triggers {
    MyScriptTriggerStorage *storage = [self componentConformingToProtocol:@protocol(MyScriptTriggerComponent)];
    if (storage == nil) {
        storage = // ... allocate / manage storage ...
        [self setComponent:storage forProtocol:@protocol(MyScriptTriggerComponent)];
    }
    storage.scriptTriggers = triggers;
}
@end
```

## Relationships

### Conforming Types

[`MDLObjectContainer`](/documentation/ModelIO/MDLObjectContainer)

[`MDLTransformStack`](/documentation/ModelIO/MDLTransformStack)

[`MDLAnimationBindComponent`](/documentation/ModelIO/MDLAnimationBindComponent)

[`MDLTransform`](/documentation/ModelIO/MDLTransform)

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherited By

[`MDLObjectContainerComponent`](/documentation/ModelIO/MDLObjectContainerComponent)

[`MDLTransformComponent`](/documentation/ModelIO/MDLTransformComponent)

---

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)