TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Need Help... May require therapy... binary data and data with no extension

Forums > iOS

I'm down a rabbit hole on a project that interests me, but has gotten out of hand. In medical imaging, there is a nose-bleeding-mind-numbing format called DICOM. I'm trying to read a DICOMDIR file, which doesn't have an extension. I believe it is a data type of some demonic kind, the details of which to me are reading like VCR instructions for the time being.

The parsing of this file is a topic for a later time.

My question for now is how can I simply locate the bloody file!

I've tried:

let urlPath = Bundle.main.url(forResource: "DICOMDIR", withExtension: "") let urlPath = Bundle.main.url(forResource: "DICOMDIR", withExtension: nil) let stringPath = Bundle.main.path(forResource: "DICOMDIR", ofType: "") let stringPath = Bundle.main.path(forResource: "DICOMDIR", ofType: nil)

I'm simply trying to output the path to the Image Text field on the starter template.

I have pulled the DICOMDIR file into the folder in Xcode, so I can see it in the project. I have a "photo.png" file in the same location, and can get the path to display.

Any thoughts? Thanks for reading.

   

This is ChatGPT's try:


func loadDicomDir() -> URL? {
    if let dicomDirURL = Bundle.main.url(forResource: "DICOMDIR", withExtension: nil) {
        return dicomDirURL
    } else {
        print("DICOMDIR file not found in the bundle.")
        return nil
    }
}

I added it to a button, but it logs DICOMDIR file not found in the bundle.

   

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.