selector to return string name

I'm trying to use UILocalizedIndexCollation's sector(for:collationStringSelector:) method. My 'for' is simply a String, and so I'm not sure what #selector() to pass in so that I just get the string itself back.

Accepted Reply

You want to use the Objective-C

-self
method. Getting this is a bit tricky. This will work:
let s = "self"
let section = col.section(for: "Foo", collationStringSelector: Selector(s))

There might be a better way but I couldn’t find one that works and doesn’t generate any warnings. Perhaps someone else will chime in.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

You want to use the Objective-C

-self
method. Getting this is a bit tricky. This will work:
let s = "self"
let section = col.section(for: "Foo", collationStringSelector: Selector(s))

There might be a better way but I couldn’t find one that works and doesn’t generate any warnings. Perhaps someone else will chime in.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

What does that string represent (title?) & what will you do w/it once you get it back?


It may be the method you've shown isn't your best friend...