Search code examples
iosiphoneswiftuipickerview

PickerView selectedValue anyObject returns nil


I'm trying to return the selectedValue of the UIPickerView called picker. The problem is that it always returns nil whatever i do. How come is this?

let done: ActionStringDoneBlock = {(picker: ActionSheetStringPicker!, selectedIndex: NSInteger!, selectedValue : AnyObject!) in
   prinln(selectedValue)    
}

Solution

  • The reason for that is unwrapping a NSInteger in done Block, try to change NSInteger! to NSInteger and problem will be fixed.

    let done: ActionStringDoneBlock = {(picker: ActionSheetStringPicker!, selectedIndex: NSInteger, selectedValue : AnyObject!) in
    println(selectedValue)
    

    }