Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift reading binary data

func getFile(forResource resource: String, withExtension fileExt: String?) -> [UInt8]? {
    // See if the file exists.    
    guard let fileUrl: URL = Bundle.main.url(forResource: resource, withExtension: fileExt) else {
        return nil
    }

    do {
        // Get the raw data from the file.
        let rawData: Data = try Data(contentsOf: fileUrl)

        // Return the raw data as an array of bytes.
        return [UInt8](rawData)
    } catch {
        // Couldn't read the file.
        return nil
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: xcode button center text 
Swift :: Swift Optional Binding (if-let 
Swift :: swift looping through array 
Swift :: cherries 
Swift :: swift memberwise initializer 
Swift :: fullscreencover swiftui 
Swift :: how to call another view controller method when button click from another ios swift 
Swift :: Iterate Over enum Cases Swift 
Swift :: code that detect input swift 
Swift :: image copy swift extension 
Swift :: struct exsmple 
Swift :: Swift Modify Tuple Element 
Swift :: How to Hide Password in Text field Swift 
Swift :: dynamic table view height without scrolling 
Swift :: print 1 line swift 
Swift :: password reset with phone number in firebase flutter 
Swift :: microsoft flight simulator uses which language 
Ruby :: create image from base64 ruby 
Ruby :: activerecord list tables 
Ruby :: remove ruby 
Ruby :: ruby check if block given 
Ruby :: rails excep 
Ruby :: safe navigation operator in ruby 
Ruby :: ruby different ways to run string interpolation 
Ruby :: ruby boolean variable 
Ruby :: new line in ruby 
Ruby :: rails filter hashes by key value 
Ruby :: Ruby instance variabnl get 
Ruby :: command to install ruby gems 
Ruby :: ruby refinement include module 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =