Re: NSRunningApplication executableURL issue in Swift
Re: NSRunningApplication executableURL issue in Swift
- Subject: Re: NSRunningApplication executableURL issue in Swift
- From: email@hidden
- Date: Wed, 11 Mar 2015 14:57:08 +0900
>> On 2015/03/11, at 14:44, Quincey Morris <email@hidden> wrote:
>>
>> On Mar 10, 2015, at 22:26 , Bavarious <email@hidden> wrote:
>>
>> Much like in Objective-C. If you write
>>
>> void someFunction(id obj) {
>> NSLog(@"%@", [obj bundleURL]);
>> }
>>
>> the compiler picks *some* method that matches that selector
>
> So how come this behavior has been imported into Swift? What problems does having it there actually solve? Other languages are going to laugh at us and take our lunch money if we have types like ‘NSURL!?’.
>
>> ―which method is undefined. This can be problematic when multiple methods have the same selector but different types; in particular, when one method has a floating-point type in its signature and another method doesn’t.
>
> That’s what I don’t understand for Swift. None of the reasons I can imagine for *not* removing this behavior from Obj-C** seem applicable to Swift.
This is simply part of the evolving state of affairs.
For now, this is part of life if you use Swift and you use objects that inherit from NSObject.
There's an impedance mismatch ever so small but annoying.
Swift hates nil or potentially nil and wants to know if something is expected to potentially be nil.
Objective-C and Cocoa built loads of incredible clever patterns with nil.
This is one extra thing you have to really get used to with Swift. You learn Swift, then learn that it effectively requires some constant special handling for NSObject's descendants.
If you're using the frameworks that's a lot of optionals and implicitly unwrapped optionals.
>
> ** such as:
>
> #1: Historical precedent (Swift is all-new source code)
> #2: Ugly cast syntax to clarify which selector is intended (Swift has ‘as!’)
> #3: Obscures full-on polymorphism (rarely used in many classes of apps, more common usage of limited polymorphism is better expressed via protocols, which are more capable in Swift)
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden