[swift-corelibs-dev] NSObject's performSelector(inBackground:with:) doesn't feel right in Swift 3

Philippe Hausler phausler at apple.com
Tue Aug 16 10:44:53 CDT 2016


> On Aug 16, 2016, at 8:42 AM, Philippe Hausler via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
> 
> Those methods should probably all belong to the same family of `perform` but it matches the method naming of:
> 
> open func performSelector(onMainThread aSelector: Selector, with arg: Any?, waitUntilDone wait: Bool, modes array: [String]?)
> 
> But perhaps the naming family should belong to this one:
> 
> open func perform(_ aSelector: Selector, on thr: Thread, with arg: Any?, waitUntilDone wait: Bool)
> 
>> On Aug 15, 2016, at 3:53 PM, Paul Hudson via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
>> 
>> Hello!
>> 
>> I just noticed that performSelectorInBackground(_:withObject:) has
>> been mapped to performSelector(inBackground:with:) in Swift 3. So:
>> 
>> performSelector(inBackground: #selector(doStuff), with: nil)
>> 
>> This seems confusing to me – the "inBackground" label has little to do
>> with the selector that is attached to it. It's possible this has been
>> through careful API review and if so I apologize. On the other hand,
>> if it's an oversight is there time for it to be looked at again?

Unfortunately per timing wise we are really late in the game to fix the names of things. It would require a full API review to push through a better name for it. (However I agree that perhaps we should rename them)

Also there were a pair of block variants added to RunLoop that falls into this family:

open func perform(inModes modes: [RunLoopMode], block: @escaping () -> Swift.Void)
open func perform(_ block: @escaping () -> Swift.Void)

>> 
>> Thank you!
>> 
>> 
>> Paul
>> --
>> Free Swift tutorials – hackingwithswift.com
>> _______________________________________________
>> swift-corelibs-dev mailing list
>> swift-corelibs-dev at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
> 
> _______________________________________________
> swift-corelibs-dev mailing list
> swift-corelibs-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev



More information about the swift-corelibs-dev mailing list