'kUTTypeData' is deprecated: first deprecated in iOS 15.0

Code snippet: NSData* itemData = itemDict[(NSString*)kUTTypeData];

As per recommendation when I use UTTypeData instead of kUTTypeData, I am getting error. If someone facing the same issue and got any resolution, please let me know.

Add a Comment

Replies

The same here for :

        kUTTypeFileURL 

        kUTTypeUTF8PlainText

despite import :

import MobileCoreServices
import UniformTypeIdentifiers

the error :

'kUTTypeFileURL' was deprecated in iOS 15.0: Use UTTypeFileURL instead.

'kUTTypeUTF8PlainText' was deprecated in iOS 15.0: Use UTTypeUTF8PlainText instead.

Seem to be :

UTType.fileURL.identifier
UTType.utf8PlainText.identifier

compiler happy :)

Thanks everyone for the response. Hi @uocram do you have anything for 'kUTTypeData', through which I can resolve this issue. Please let me know I will be happy to try.

  • Can you show what you have tried? The answer of uocram would work for kUTTypeData with a similar manner.

  • The deprecations issue still exists for iOS15 of 'kUTTypeData' for pasteboard.

Add a Comment

Hi @OOPer I have tried the following but still having the issue. I have attached some code snippet for reference.

The import part:

The implementation part:

  • Please show your code as text, using Code Block.

Add a Comment

A simplified example of using UTTypeData in Objective-C:

#import "MyClass.h"
@import UniformTypeIdentifiers;

@implementation MyClass
- (void)testWithDictionary:(NSDictionary *)itemDict {
    NSData *itemData = itemDict[UTTypeData.identifier];
}
@end

UTTypeData is a constant declared in the module UniformTypeIdentifiers. You should not declare another UTTypeData in your code.

import UniformTypeIdentifiers

    static var draggableType = UTType.data.identifier

Apple doc :

Type Property

data A base type that represents any sort of byte stream, including files and in-memory data.

Discussion

The identifier for this type is public.data. This type conforms to UTTypeItem.