Re: [swift-users] Finding resources.

2017-10-31 Thread Nate Birkholz via swift-users
Hi, Moughees. This mailing list is for issues found developing with the Swift language and not for help with third party frameworks such as Vapor. Looking at the page for Vapor at https://github.com/vapor/vapor it seems that they use a Slack channel for support. I would suggest you install a Slack

Re: [swift-users] Expression was too complex to be solved in reasonable time

2017-10-24 Thread Nate Birkholz via swift-users
Thanks, Slava! On Tue, Oct 24, 2017 at 3:05 PM, Slava Pestov wrote: > > > On Oct 24, 2017, at 3:05 PM, Nate Birkholz via swift-users < > swift-users@swift.org> wrote: > > Doing a tutorial from RayWenderlich. https://www. > raywenderlich.com/125313/make-game-like-candy

[swift-users] Expression was too complex to be solved in reasonable time

2017-10-24 Thread Nate Birkholz via swift-users
Doing a tutorial from RayWenderlich. https://www.raywenderlich.com/125313/make-game-like-candy-crush-spritekit-swift-part-4 I have four bool values: topLeft, bottomLeft, topRight, and bottomRight the following line throws an error: let value = Int(topLeft.hashValue) | Int(topRight.hashValue) << 1

[swift-users] Lifetime of objects in `class` methods

2017-07-24 Thread Nate Birkholz via swift-users
If I use these two classes: class MotionManager { class func doTheThing(completionHandler: @escaping (CMDeviceMotion?)->() ) { print("in") let manager = CMMotionManager() manager.deviceMotionUpdateInterval = 0.01 manager.startDeviceMotionUpdates(to: .ma

Re: [swift-users] Calling default implementation of protocol methods as selectors

2017-06-04 Thread Nate Birkholz via swift-users
d errors >>>> >>>> On Jun 3, 2017, at 9:38 PM, Geordie Jay wrote: >>>> >>>> I am dealing with a variant of this on Android right now. I have just >>>> subclassed e.g. UITapGestureRecognizer to perform the 2nd variant above and >>>> externally accept a closure

Re: [swift-users] Calling default implementation of protocol methods as selectors

2017-06-04 Thread Nate Birkholz via swift-users
rrors >>>> >>>> On Jun 3, 2017, at 9:38 PM, Geordie Jay wrote: >>>> >>>> I am dealing with a variant of this on Android right now. I have just >>>> subclassed e.g. UITapGestureRecognizer to perform the 2nd variant above and >>>> exter

Re: [swift-users] Calling default implementation of protocol methods as selectors

2017-06-04 Thread Nate Birkholz via swift-users
onTap: (() -> Void)?) { >> self.onTap = onTap >> super.init(target: self, action: #selector(internalTapHandler)) >> } >> >> @objc private func internalTapHandler() { >> onTap?() >> } >> } >> >> class Baz: Foo { >> init() { >>

Re: [swift-users] Calling default implementation of protocol methods as selectors

2017-06-04 Thread Nate Birkholz via swift-users
ate func internalTapHandler() { > onTap?() > } > } > > class Baz: Foo { > init() { > let tapRecognizer = TapGestureRecognizer(onTap: self.bar) > } > } > > > Cheers, > Geordie > On Sat 3. Jun 2017 at 16:53, Nate Birkholz via swift-users < > swift-users@swift

Re: [swift-users] Calling default implementation of protocol methods as selectors

2017-06-04 Thread Nate Birkholz via swift-users
(onTap: self.bar) > } > } > > > Cheers, > Geordie >> On Sat 3. Jun 2017 at 16:53, Nate Birkholz via swift-users >> wrote: >> Thanks, the second had occurred to me, but felt a little too much like in >> practice it would make the code harder to understan

Re: [swift-users] Calling default implementation of protocol methods as selectors

2017-06-03 Thread Nate Birkholz via swift-users
az: Foo { > > init() { > > let tapRecognizer = UITapGestureRecognizer(target: self, action: > #selector(delegate)) > > } > > > > @objc func delegate() { > > bar() > > } > > } > > > Zhao Xin > > > > > >

[swift-users] Calling default implementation of protocol methods as selectors

2017-06-02 Thread Nate Birkholz via swift-users
protocol Foo: class { func bar() } extension Foo { func bar() { print("bar") } } class Baz: Foo { init() { let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(bar)) } } the #selector tells me: "Argument of '#selector' refers to instance

Re: [swift-users] Passing value types or members of value types?

2017-05-06 Thread Nate Birkholz via swift-users
Classes and structs are different things. Classes are passed by reference, structs are passed by value with copy on write. Strings and Arrays are structs, not classes. On Sat, May 6, 2017 at 10:24 PM, Kelvin Ma wrote: > I hear that a lot but why do all the official sources sound like > copy-on-

Re: [swift-users] edit array

2017-04-26 Thread Nate Birkholz via swift-users
Relatively straightforward to write this, which usually has meant "no" to adding something to the standard library. (Not that I agree with that measure.) Sent from my iPhone, please excuse brevity and errors > On Apr 26, 2017, at 11:13 AM, Ole Begemann via swift-users > wrote: > > On 26.04.20

Re: [swift-users] odd `==` `!=` behavior with class that inherits `NSObject`

2017-04-18 Thread Nate Birkholz via swift-users
I'm not sure exactly how class declarations interact with the scope of a do{ } statement. I declare a new static function inside your do{ } scope and it works fine, but something about the mapping of `==` and `!=` to `isEqual` in NSObject seems to be confused by the scope of the do{ } block. I'm n

Re: [swift-users] odd `==` `!=` behavior with class that inherits `NSObject`

2017-04-18 Thread Nate Birkholz via swift-users
Your issue seems to be that you created a custom implementation for the `==` operator but not one for the `!=` operator. If I add a custom implementation for `!=` I get the results you expected. Tthe default implementation of NSObject's `isEqual` is a test for identity, like the `===` in Swift. So

Re: [swift-users] Get class of object in Swift 2.3

2016-11-10 Thread Nate Birkholz via swift-users
Never mind, .dynamicType works, it just doesn't autocomplete any more. /facepalm On Thu, Nov 10, 2016 at 11:54 AM, Nate Birkholz wrote: > self.dynamicType doesn't work any more, but type(of: self) is just Swift > 3.0 So how do i get the class? > > Use case in a unit test: > > let bundle = NSBund

[swift-users] Get class of object in Swift 2.3

2016-11-10 Thread Nate Birkholz via swift-users
self.dynamicType doesn't work any more, but type(of: self) is just Swift 3.0 So how do i get the class? Use case in a unit test: let bundle = NSBundle(forClass: type(of: self)) -- Nate Birkholz ___ swift-users mailing list swift-users@swift.org https:

Re: [swift-users] Swift migration bug

2016-10-03 Thread Nate Birkholz via swift-users
I did it then you'd never hear when it was fixed, and wouldn't get > the chance to test it on your own code and say "no, you fixed the wrong > thing". :-) > > >> On Oct 3, 2016, at 10:12, Nate Birkholz via swift-users >> wrote: >> &g

Re: [swift-users] Swift migration bug

2016-10-03 Thread Nate Birkholz via swift-users
Then Jordan Rose closed it as not a Swift bug. :) On Mon, Oct 3, 2016 at 2:03 AM, Alex Blewitt wrote: > On 30 Sep 2016, at 19:30, Nate Birkholz via swift-users < > swift-users@swift.org> wrote: > > I found a bug in Swift 2.3 migration in the XCUITests, not sure if the bug >

Re: [swift-users] Swift migration bug

2016-10-03 Thread Nate Birkholz via swift-users
https://bugs.swift.org/browse/SR-2837 On Mon, Oct 3, 2016 at 2:03 AM, Alex Blewitt wrote: > On 30 Sep 2016, at 19:30, Nate Birkholz via swift-users < > swift-users@swift.org> wrote: > > I found a bug in Swift 2.3 migration in the XCUITests, not sure if the bug > goes to

[swift-users] Swift migration bug

2016-09-30 Thread Nate Birkholz via swift-users
I found a bug in Swift 2.3 migration in the XCUITests, not sure if the bug goes to swift.org or to Apple. UI test generator uses the syntax (XCUIElement).children(matching: .other) but the compiler only recognizes childrenMatchingType(.Other), and you have to manually change the instances. Makes g

Re: [swift-users] Is there method indiicate current thread is mainthread in swift?

2016-07-13 Thread Nate Birkholz via swift-users
Is this a change to NSThread in the release, or to the language, dropping empty () when calling methods? If the latter, what proposal is it? i can't find it. On Wed, Jul 13, 2016 at 12:41 AM, Jose Cheyo Jimenez via swift-users < swift-users@swift.org> wrote: > //swift 2.2+ > NSThread.isMainThread

Re: [swift-users] Switch based on let

2016-07-08 Thread Nate Birkholz via swift-users
gt;> On Fri, Jul 08 2016 at 11:11:04 AM, Nate Birkholz via swift-users >> wrote: >> > This gives an error, expecting a colon (:) after object on every case. >> > >> > I wanted to be sure I wasn't missing something in my syntax (nor some >>

Re: [swift-users] Switch based on let

2016-07-08 Thread Nate Birkholz via swift-users
> default: > > break > > } > > } > > On Fri, Jul 8, 2016 at 10:11 AM, Nate Birkholz via swift-users < > swift-users@swift.org> wrote: > >> This looks like it doesn't work (swift 2.x), but wanted to be sure it's >> no

[swift-users] Switch based on let

2016-07-08 Thread Nate Birkholz via swift-users
This looks like it doesn't work (swift 2.x), but wanted to be sure it's not supported: class Superclass {} class Subclass1 : Superclass {} class Subclass2 : Superclass {} class Subclass3 : Superclass {} let sc1 = Subclass1() let sc2 = Subclass2() let sc3 = Subclass3() let objects : [Superclass]

Re: [swift-users] @noescape

2016-05-17 Thread Nate Birkholz via swift-users
pipermail/swift-evolution/Week-of-Mon-20151214/003748.html > > Cheers, > > — A > > On May 16, 2016, at 12:43 PM, Nate Birkholz via swift-users < > swift-users@swift.org> wrote: > > Well that was where I was going next, heh. > > On Mon, May 16, 2016 at 9:

Re: [swift-users] @noescape

2016-05-16 Thread Nate Birkholz via swift-users
Well that was where I was going next, heh. On Mon, May 16, 2016 at 9:41 AM, Jens Alfke wrote: > > On May 16, 2016, at 9:37 AM, Nate Birkholz via swift-users < > swift-users@swift.org> wrote: > > I understand how @noescape works, and some of its benefits, I *think*, but

[swift-users] @noescape

2016-05-16 Thread Nate Birkholz via swift-users
I understand how @noescape works, and some of its benefits, I *think*, but if I am correct, it almost seems like it should be added automatically to my closure definitions until it becomes clear that the closure has to escape its context, much like I tend to declare variables as `let` until it beco

Re: [swift-users] Stored Property, Externally Read-Only

2016-04-29 Thread Nate Birkholz via swift-users
That's correct. On Fri, Apr 29, 2016 at 8:52 AM, David Sweeris via swift-users < swift-users@swift.org> wrote: > Yep, declare it like this: > public private(set) var lastUpdated: NSDate? > > At least I’m pretty sure that’s the syntax. I don’t have Xcode in front of > me to double-check. > > HTH >

Re: [swift-users] FlatMap and Casting

2016-04-21 Thread Nate Birkholz via swift-users
; > 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, Nate Birkholz via swift-users < > swift-users@swift.org> wrote: > &g

[swift-users] FlatMap and Casting

2016-04-21 Thread Nate Birkholz via swift-users
myView.layer.sublayers returns an array of CALayer objects. Some of my sublayers are CAShapeLayers. I want to act on the CAShapeLayer objects. Shouldn't flatMap allow me to conditionally cast CALayers to CAShapeLayers? i.e. let layers = myView.layer.sublayers.flatMap({ $0 as? CAShapeLayer }) The