Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
iOS Documentation
SDLFile

SDLFile Class Reference

Section Contents

Overview

Crates an SDLFile from a file

persistent

Whether or not the file should persist on disk between car ignition cycles.

Objective-C

@property (nonatomic, readonly, getter=isPersistent) BOOL persistent;

Swift

var isPersistent: Bool { get }

overwrite

Whether or not the file should overwrite an existing file on the remote disk with the same name.

Objective-C

@property (nonatomic) BOOL overwrite;

Swift

var overwrite: Bool { get set }

name

The name the file should be stored under on the remote disk. This is how the file will be referenced in all later calls.

Objective-C

@property (nonatomic, copy, readonly) NSString *_Nonnull name;

Swift

var name: String { get }

fileURL

The url the local file is stored at while waiting to push it to the remote system. If the data has not been passed to the file URL, this will be nil.

Objective-C

@property (nonatomic, copy, readonly, nullable) NSURL *fileURL;

Swift

var fileURL: URL? { get }

data

The binary data of the SDLFile. If initialized with data, this will be a relatively quick call, but if initialized with a file URL, this is a rather expensive call the first time. The data will be cached in RAM after the first call.

Objective-C

@property (nonatomic, copy, readonly) NSData *_Nonnull data;

Swift

var data: Data { get }

fileSize

The size of the binary data of the SDLFile.

Objective-C

@property (nonatomic, readonly) unsigned long long fileSize;

Swift

var fileSize: UInt64 { get }

fileType

The system will attempt to determine the type of file that you have passed in. It will default to BINARY if it does not recognize the file type or the file type is not supported by SDL.

Objective-C

@property (nonatomic, strong, readonly) SDLFileType _Nonnull fileType;

Swift

var fileType: SDLFileType { get }

inputStream

A stream to pull binary data from a SDLFile. The stream only pulls required data from the file on disk or in memory. This reduces memory usage while uploading a large file to the remote system as each chunk of data can be released immediately after it is uploaded.

Objective-C

@property (nonatomic, readonly) NSInputStream *_Nonnull inputStream;

Swift

var inputStream: InputStream { get }

isStaticIcon

Describes whether or not this file is represented by static icon data. The head unit will present its representation of the static icon concept when sent this data.

A file that represents a static icon may not be uploaded via the File Manager. It must be set using the Screen Manager.

Support for this feature may vary by system, but it will generally be more supported in soft buttons and menus.

Objective-C

@property (nonatomic, readonly) BOOL isStaticIcon;

Swift

var isStaticIcon: Bool { get }

-init

Initializer unavailable

Objective-C

- (nonnull instancetype)init;

-initWithFileURL:name:persistent:

The designated initializer for an SDL File. The only major property that is not set using this is “overwrite”, which defaults to NO.

Objective-C

- (nonnull instancetype)initWithFileURL:(nonnull NSURL *)url
                                   name:(nonnull NSString *)name
                             persistent:(BOOL)persistent;

Swift

init(fileURL url: URL, name: String, persistent: Bool)

Parameters

url

The file URL pointing to the local data that will be pushed to the remote system.

name

The name that the file will be stored under on the remote system and how it will be referenced from the local system. The max file name length may vary based on remote filesystem limitations.

persistent

Whether or not the file will persist between ignition cycles.

Return Value

An SDLFile object.

+persistentFileAtFileURL:name:

Create an SDL file using a local file URL.

This is a persistent file, it will be persisted through sessions / ignition cycles. You will only have a limited space for all files, so be sure to only persist files that are required for all or most sessions. For example, menu artwork should be persistent.

Ephemeral files should be created using ephemeralFileAtURL:name:

Warning

If this is not a readable file, this will return nil

Objective-C

+ (nonnull instancetype)persistentFileAtFileURL:(nonnull NSURL *)url
                                           name:(nonnull NSString *)name;

Parameters

url

The url to the file that should be uploaded.

name

The name of the file that will be used to reference the file in the future (for example on the remote file system). The max file name length may vary based on remote filesystem limitations.

Return Value

An instance of this class, or nil if a readable file at the path could not be found.

+fileAtFileURL:name:

Create an SDL file using a local file URL.

This is an ephemeral file, it will not be persisted through sessions / ignition cycles. Any files that you do not know you will use in future sessions should be created through this method. For example, album / artist artwork should be ephemeral.

Persistent files should be created using persistentFileAtURL:name:

Warning

If this is not a readable file, this will return nil

Objective-C

+ (nonnull instancetype)fileAtFileURL:(nonnull NSURL *)url
                                 name:(nonnull NSString *)name;

Swift

convenience init(atFileURL url: URL, name: String)

Parameters

url

The url to the file on disk that will be uploaded

name

The name of the file that will be used to reference the file in the future (for example on the remote file system). The max file name length may vary based on remote file system limitations.

Return Value

An instance of this class, or nil if a readable file at the url could not be found.

-initWithData:name:fileExtension:persistent:

Create an SDL file using raw data. It is strongly preferred to pass a file URL instead of data, as it is currently held in memory until the file is sent.

Objective-C

- (nonnull instancetype)initWithData:(nonnull NSData *)data
                                name:(nonnull NSString *)name
                       fileExtension:(nonnull NSString *)extension
                          persistent:(BOOL)persistent;

Swift

init(data: Data, name: String, fileExtension extension: String, persistent: Bool)

Parameters

data

The raw data to be used for the file

name

The name of the file that will be used to reference the file in the future (for example on the remote file system). The max file name length may vary based on remote file system limitations.

extension

The file extension. For example “png”. Currently supported file extensions are: “bmp”, “jpg”, “jpeg”, “png”, “wav”, “mp3”, “aac”, “json”. All others will be sent as binary files.

persistent

Whether or not the remote file with this data should be persistent

Return Value

An instance of this class

+persistentFileWithData:name:fileExtension:

Create an SDL file using raw data. It is strongly preferred to pass a file URL instead of data, as it is currently held in memory until the file is sent.

This is a persistent file, it will be persisted through sessions / ignition cycles. You will only have a limited space for all files, so be sure to only persist files that are required for all or most sessions. For example, menu artwork should be persistent.

Objective-C

+ (nonnull instancetype)persistentFileWithData:(nonnull NSData *)data
                                          name:(nonnull NSString *)name
                                 fileExtension:(nonnull NSString *)extension;

Parameters

data

The raw data to be used for the file

name

The name of the file that will be used to reference the file in the future (for example on the remote file system). The max file name length may vary based on remote file system limitations.

extension

The file extension. For example “png”. Currently supported file extensions are: “bmp”, “jpg”, “jpeg”, “png”, “wav”, “mp3”, “aac”, “json”. All others will be sent as binary files.

Return Value

An instance of this class

+fileWithData:name:fileExtension:

Create an SDL file using raw data. It is strongly preferred to pass a file URL instead of data, as it is currently held in memory until the file is sent.

This is an ephemeral file, it will not be persisted through sessions / ignition cycles. Any files that you do not know you will use in future sessions should be created through this method. For example, album / artist artwork should be ephemeral.

Objective-C

+ (nonnull instancetype)fileWithData:(nonnull NSData *)data
                                name:(nonnull NSString *)name
                       fileExtension:(nonnull NSString *)extension;

Swift

convenience init(data: Data, name: String, fileExtension extension: String)

Parameters

data

The raw data to be used for the file

name

The name of the file that will be used to reference the file in the future (for example on the remote file system). The max file name length may vary based on remote file system limitations.

extension

The file extension. For example “png”. Currently supported file extensions are: “bmp”, “jpg”, “jpeg”, “png”, “wav”, “mp3”, “aac”, “json”. All others will be sent as binary files.

Return Value

An instance of this class

View on GitHub.com
Previous Section Next Section