Files
MapLibreParticleLab/platform/darwin/src/NSURL+MGLAdditions.m
Minh Nguyễn 1daba5d04b [ios, macos] Accept absolute file paths as style URLs (#6026)
It turns out that mbgl::AssetFileSource supports absolute file URLs in addition to relative file URLs. So replace the file: scheme with asset: while percent-escaping as necessary.

Also added amsterdam.geojson to macos.xcodeproj for consistency with ios.xcodeproj.
2016-08-16 10:17:11 +02:00

22 lines
743 B
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#import "NSURL+MGLAdditions.h"
@implementation NSURL (MGLAdditions)
- (nullable NSURL *)mgl_URLByStandardizingScheme {
if (!self.scheme) {
// Relative file URL, already escaped (in order to create the NSURL).
// Assume a relative path into the application’s resource folder.
return [NSURL URLWithString:[@"asset://" stringByAppendingString:self.absoluteString]];
} else if (self.fileURL) {
// Absolute file URL, so construct a new URL using the unescaped path.
NSURLComponents *components = [[NSURLComponents alloc] init];
components.scheme = @"asset";
components.host = @"";
components.path = self.path;
return components.URL;
}
return self;
}
@end