Skip to content

Commit a34482c

Browse files
committed
kUTTagClassFilenameExtension deprecated
1 parent 413eb41 commit a34482c

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ elseif(APPLE)
2727
find_library(COCOA_LIB Cocoa REQUIRED)
2828
find_library(WEBKIT_LIB WebKit REQUIRED)
2929
find_library(QUARTZCORE_LIB QuartzCore REQUIRED)
30-
set(LIBS nlohmann_json::nlohmann_json ${COCOA_LIB} ${WEBKIT_LIB} ${QUARTZCORE_LIB} CURL::libcurl)
30+
find_library(UNIFORMTYPEIDENTIFIERS_FRAMEWORK UniformTypeIdentifiers REQUIRED)
31+
set(LIBS nlohmann_json::nlohmann_json ${COCOA_LIB} ${WEBKIT_LIB} ${QUARTZCORE_LIB} ${UNIFORMTYPEIDENTIFIERS_FRAMEWORK} CURL::libcurl)
3132
elseif(EMSCRIPTEN)
3233
set(LIBS nlohmann_json::nlohmann_json)
3334
endif()

src/platform/macos.mm

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "webview_candidate_window.hpp"
22
#include <QuartzCore/QuartzCore.h>
3+
#include <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
34
#include <WebKit/WKWebView.h>
45

56
NSString *const F5mErrorDomain = @"F5mErrorDomain";
@@ -125,18 +126,11 @@ - (void)webView:(WKWebView *)webView
125126

126127
- (NSString *)mimeTypeForPath:(NSString *)path {
127128
NSString *pathExtension = [path pathExtension];
128-
CFStringRef type = UTTypeCreatePreferredIdentifierForTag(
129-
kUTTagClassFilenameExtension, (__bridge CFStringRef)pathExtension,
130-
NULL);
129+
UTType *type = [UTType typeWithFilenameExtension:pathExtension];
131130
NSString *mimeType = @"application/octet-stream";
132-
if (!type)
133-
return mimeType;
134-
CFStringRef mimeTypeRef =
135-
UTTypeCopyPreferredTagWithClass(type, kUTTagClassMIMEType);
136-
if (mimeTypeRef) {
137-
mimeType = (NSString *)mimeTypeRef;
131+
if (type && type.preferredMIMEType) {
132+
mimeType = type.preferredMIMEType;
138133
}
139-
CFRelease(type);
140134
return mimeType;
141135
}
142136

0 commit comments

Comments
 (0)