nilesh
nilesh

Reputation: 55

'pathExtension' is unavailable: Use pathExtension on URL instead

This code gives an error 'pathExtension' is unavailable: Use pathExtension on URL instead:

if originalAudioFormat == "MP2" || originalAudioFormat == "BWFMP2" {
                    SourceFileNameWithPath = decodeMp2ToWav() 

                        if SourceFileNameWithPath.pathExtension != "wav" { //error at this line
                            print("save File as PCM Fehler: \(SourceFileNameWithPath)")
                            return
                            }

Upvotes: 0

Views: 379

Answers (1)

vadian
vadian

Reputation: 285082

Basically it's highly recommended to prefer always URLs to String paths.

Alternatively you can bridge the string to NSString

(SourceFileNameWithPath as NSString).pathExtension

Please conform to the naming convention that variable names start with a lowercase letter.

Upvotes: 1

Related Questions