Re: [swift-users] Cast CFString to String

2017-12-05 Thread Dennis Weissmann via swift-users
default: >self = .unknown >} >} > > because there is a `String(_ cocoaString: NSString)` initializer in > Foundation. > > Regards, Martin > > >> Am 05.12.2017 um 10:09 schrieb Dennis Weissmann via swift-users >> : >> &

Re: [swift-users] Cast CFString to String

2017-12-05 Thread Dennis Weissmann via swift-users
I found a related bug here: https://bugs.swift.org/browse/SR-6204 > On Dec 5, 2017, at 10:10 AM, Dennis Weissmann via swift-users > wrote: > > Hi swift-users, > > I have found another weird behavior (IMO) and wanted to ask for the right way > to handle this: > &g

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-06 Thread Dennis Weissmann via swift-users
Hey Charles, Thanks for going through this with me :) I'm not sure whether or not this is a compiler bug (that's partially why I posted it here), although I have the feeling that *something* is definitely wrong. Funnily enough, the following code shows 3 compiler warnings which are incorrect:

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-05 Thread Dennis Weissmann via swift-users
> You can delete the default case here, and your switch will still be exhaustive That's exactly my problem! It is *not*. When I delete the default clause, the compiler warns that the switch is not exhaustive and fixits suggest to add the "missing" deprecated cases. - Dennis > On Nov 5, 2017, at

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-05 Thread Dennis Weissmann via swift-users
Hi Charles, I do believe you :) The problem is that this doesn't work without a compiler warning if you switch over every case except for the deprecated ones because then the compiler warns that "default will never be executed". As per my first mail feel free to try this out in a playground:

Re: [swift-users] Handle deprecated enum cases from a library

2017-11-05 Thread Dennis Weissmann via swift-users
, which I really want to avoid) 🤔 - Dennis Sent from my iPhone >> On 4. Nov 2017, at 10:42 PM, Charles Srstka wrote: >> >> On Nov 4, 2017, at 9:38 AM, Dennis Weissmann via swift-users >> wrote: >> >> Hi swift-users, >> >> In a project (iOS

[swift-users] Handle deprecated enum cases from a library

2017-11-04 Thread Dennis Weissmann via swift-users
Hi swift-users, In a project (iOS 11 only) we use Touch ID for authentication and handle errors like so: private func handleLocalAuthenticationError(_ error: LAError) { switch error.code { case .userCancel, .appCancel, .systemCancel: // Handle cancelation case .authentication

Re: [swift-users] weak self

2017-05-01 Thread Dennis Weissmann via swift-users
> On May 1, 2017, at 5:32 PM, Rien wrote: > >> >> On 01 May 2017, at 16:59, Dennis Weissmann wrote: >> >>> >>> On May 1, 2017, at 4:46 PM, Rien via swift-users >>> wrote: >>> >>> In my code I use a lot of queues. And (very often) I will use [weak self] >>> to prevent doing things when ‘s

Re: [swift-users] weak self

2017-05-01 Thread Dennis Weissmann via swift-users
> On May 1, 2017, at 4:46 PM, Rien via swift-users > wrote: > > In my code I use a lot of queues. And (very often) I will use [weak self] to > prevent doing things when ‘self’ is no longer available. > > Now I am wondering: how does the compiler know that [weak self] is referenced? > > I am

Re: [swift-users] Designable Protocols

2017-04-18 Thread Dennis Weissmann via swift-users
Are you sure that's because it's defined in a protocol and not because it's a `CGColor`. Can you try it with `UIColor`? I don't think CG types are supported with `@IBInspectable`. - Dennis Sent from my iPhone > On 19. Apr 2017, at 4:43 AM, Cavelle Benjamin via swift-users > wrote: > > I don

Re: [swift-users] Is there any talk about overloading enum cases with associated values?

2016-11-26 Thread Dennis Weissmann via swift-users
I would love to have that! Unfortunately, I didn’t find the time yet to think it through and write a proposal. I often use enums for modeling server calls in small apps and prototypes, something along the lines of public enum Client { private static let baseURLComponent = URL(string: "")!

Re: [swift-users] Xcode8 Swift 3.0 new API

2016-06-28 Thread Dennis Weissmann via swift-users
I am also interested in the new API and cannot find it on Darwin :( Will this be available in seed 2? - Dennis Sent from my iPhone > On Jun 18, 2016, at 1:57 PM, Kostiantyn Koval via swift-users > wrote: > > Hi everyone, > > In "What's New in Foundation for Swift” WWDC session there were ann

Re: [swift-users] Initializing a UIColor

2016-05-11 Thread Dennis Weissmann via swift-users
Huh! There’s a new overload for that initializer: The one that takes CGFloats is the one that was there before, but the one taking Floats is new! You can work around like this: let color = UIColor(red: CGFloat(0.892), green: CGFloat(0.609), blue: CGFloat(0.048), alpha: CGFloat(1.000)) or le

Re: [swift-users] String initializers and developer ergonomics

2016-05-07 Thread Dennis Weissmann via swift-users
Hi Austin, I further “swiftyfied” the code to this (swift-DEVELOPMENT-SNAPSHOT-2016-05-03-a): import Foundation let N = 1_000_000 func generateTestData() -> [String] { return (0.. [String] { return s.characters.split(separator: sep, omittingEmptySubsequences: false) .m

Re: [swift-users] Tuple Member Extraction in Closure Parameters

2016-05-05 Thread Dennis Weissmann via swift-users
ts added to Swift >> it should be a general feature for all functions, not just on closures. >> There are a lot of design directions and subtleties that would need to be >> explored. I doubt it is something that will be considered in the Swift 3 >> timeframe. >> >>

Re: [swift-users] Tuple Member Extraction in Closure Parameters

2016-05-05 Thread Dennis Weissmann via swift-users
Thanks Krzysztof, you’re right! I totally forgot about that neat feature. However, there’s no way to do this directly in the parameter list, right? Do you think such feature should exist? - Dennis > On May 5, 2016, at 4:19 PM, Krzysztof Siejkowski > wrote: > >> >> A workaround is to declare

[swift-users] Tuple Member Extraction in Closure Parameters

2016-05-05 Thread Dennis Weissmann via swift-users
Hi swift-users, Is it possible to “extract” the `tuple` tuple in the following code directly into two `Int` variables (`tuple` is of type `(Int, Int)`)? let a = [0,1,2,3,4,5,6,7,8,9] let b = [0,1,2,3,4,5,6,7,8,9] let c = zip(a,b).reduce(0) { acc, tuple in acc + tuple.0 + tuple.1 } Like so (d

Re: [swift-users] FlatMap and Casting

2016-04-21 Thread Dennis Weissmann via swift-users
Since sublayers are optional you’re calling the the flatMap function on Optionals, which behaves differently. let layers = myView.layer.sublayers?.flatMap({ $0 as? CAShapeLayer }) // sublayers?. instead of sublayers. should fix the problem :) - Dennis > On Apr 21, 2016, at 9:53 PM,

Re: [swift-users] Swift 3.0

2016-04-17 Thread Dennis Weissmann via swift-users
Thanks Brent! This solved my different but related issue on iOS: Taking the standard template for a Master-Detail Application with Core Data and making all the changes so that it compiles, leads to NSFetchedResultsControllerDelegate’s controller(_:didChange:at:for:newIndexPath:) function not b

Re: [swift-users] Swift 3.0

2016-04-17 Thread Dennis Weissmann via swift-users
Hey Marc, You didn’t explicitly state the problem you’re running into but I assume you can’t build the app. As others have noticed (http://comments.gmane.org/gmane.comp.lang.swift.user/1689) the latest development snapshot is broken. - Dennis > On Apr 17, 2016, at 7:18 PM, Marco S Hyman via