I am working with the ActionSheetPicker 3.0 (https://github.com/skywinder/ActionSheetPicker-3.0) picker and am having a newbie problem of working with the return values from the ActionSheetMultipleStringPicker. I've got the control running and can return values from it, but I want to be able to put the return values from the picker into separate variables or into something that I can join together. I've found numerous examples, but can't figure out how to get them to work.
What I think I've found through debugging is that ActionSheetMultipleStringPicker returns an array of Any?.
Debugging shows the following:
values Any? some payload_data_0 Builtin.RawPointer 0x60800044fdb0 0x000060800044fdb0 -> 0x000000010dacddd8 (void *)0x000000010dacdf18: __NSArrayI payload_data_1 Builtin.RawPointer 0x335392d30 0x0000000335392d30 payload_data_2 Builtin.RawPointer 0x10d28d798 0x000000010d28d798 libobjc.A.dylib`objc_retainAutoreleasedReturnValue + 35 instance_type Builtin.RawPointer 0x60800005d5c8 0x000060800005d5c8
values is the return value from the picker.
A couple things that I've tried are:
let stringText: String? = String(describing: values)
print(stringText)
This prints:
Optional("Optional(<__NSArrayI 0x60800044be20>(\nOne,\nMany,\naaa\n)\n)")
I've also tried:
print("\(values as! NSArray)")
This is the closest I've gotten to the results I'm looking for which is:
( One, Many, aaa )
Can anyone provide some assistance getting the value of 'values' into something that I can separate into three different string variables?
My code for the picker is:
let a = ActionSheetMultipleStringPicker.init(title: "Fertilizer Setup", rows: [
// TODO: Read values from database
["One", "Two", "A lot"],
["Many", "Many more", "Infinite"],
["aaa","sss","ccc","xxxx"]
], initialSelection: [0, 0, 0],
doneBlock: {
picker, indexes, values in
let stringText: String? = String(describing: values)
print(stringText)
print("\(values as! NSArray)")
},
cancel: {ActionMultipleStringCancelBlock in return }, origin: sender)
a?.setCancelButton(UIBarButtonItem(title: "My own title", style: UIBarButtonItemStyle.plain, target: self, action: nil))
a?.show()