1 year ago

#298441

test-img

Ali madhoun

Thread 1: signal SIGINT when getting a value from NSDictionary

I'm trying to get values from NSDictionary using the inbuilt get() func, but each time i use the get func the app crash, and xcode doesn’t print any message except "Thread 1: signal SIGINT". but, when I try get the value directly by using dicName["key"], it does work. does anyone has an explanation for this, and how can i fix this issue?

func getLanguageLabel(origValue:String, key:String) -> String{
    let langs:NSDictionary! = GeneralFunctions.languageLabels
    //this works fine
    let lang = langs[key]
    //this makes the crash!
    let lngValue = langs.get(key)
    return lngValue
}

the get func in the extension

extension NSDictionary{
func get(_ key:String) -> String{

    let value = self.value(forKey: key)
    
    if(value != nil){
        return String(describing: value!)
    }
    
    return ""
}

}

Thanks in advance

swift

iphone

xcode

nsdictionary

0 Answers

Your Answer

Accepted video resources