Re: [swift-users] Initialization Catch-22?

2017-09-25 Thread Kenny Leung via swift-users
Hi Howard. Yes, this would make it compile, but it still would not solve the issues that make it wrong in my mind: 1. I would have to make it a var, but it should not be mutable. 2. It’s not optional. Without it, the PDAudioPlayer class could not function. Of course, this is just being stubbor

Re: [swift-users] Initialization Catch-22?

2017-09-25 Thread Kenny Leung via swift-users
Hi Muthu. Thanks for the suggestion. I don’t want to do that because failure to create the AudioQueue should mean failure to create the AudioPlayer itself. -Kenny > On Sep 25, 2017, at 6:33 PM, somu subscribe wrote: > > Hi Kenny, > > You could use a lazy var and initialise it with a closur

Re: [swift-users] Initialization Catch-22?

2017-09-25 Thread somu subscribe via swift-users
Hi Kenny, You could use a lazy var and initialise it with a closure. class PDAudioPlayer { //Would be created lazily when first invoked lazy var mQueue : AudioQueueRef = { //create an audioQueue and return that instance return audioQueue }() } Thanks and regards, Mu

[swift-users] Initialization Catch-22?

2017-09-25 Thread Kenny Leung via swift-users
Hi All. I’m trying to implement the AudioQueue example from Apple in Swift, and keep it as Swifty as I can. I’ve run into a problem where I have a let ivar for the AudioQueue, but the only way to initialize that let ivar is to pass a block to the function that creates the AudioQueue. I get the

Re: [swift-users] NSRange error in docker

2017-09-25 Thread Людвиг Вальда Васкес via swift-users
Ah, seems i’m wrong in my conclusions, methods and properties in those extensions are marked as public, which makes them accessible from outside of Foundation module. Sorry for confusing. Best regards, Ludwig > 26 сент. 2017 г., в 1:36, Людвиг Вальда Васкес via swift-users > написал(а): > >

Re: [swift-users] NSRange error in docker

2017-09-25 Thread Людвиг Вальда Васкес via swift-users
I’m not sure. As far as i know only extension which declare a protocol conformance for a type will have same visibility as type they implement it for. But if you simply extend a type, this extension will be internal by default. Best regards, Ludwig > 26 сент. 2017 г., в 1:28, Jordan Rose напис

Re: [swift-users] NSRange error in docker

2017-09-25 Thread Jordan Rose via swift-users
That's not how extensions in Swift work. All of those functions are definitely available. Barbara, can you post your source somewhere? And can you check that your Docker image is actually new enough, using `swift --version`? (The Swift project doesn't publish an official Docker image, so unless

Re: [swift-users] NSRange error in docker

2017-09-25 Thread Людвиг Вальда Васкес via swift-users
Interesting, those extensions aren't public for some reason which prevents their usage from outside of Foundation module. I’m curious if that was intentional due to unfinished work or something or they just forgot to export them. Best regards, Ludwig > 25 сент. 2017 г., в 16:40, Barbara Reicha

[swift-users] UnsafeMutablePointer: Ambiguous use of init (but not always)

2017-09-25 Thread nyg nyg via swift-users
Hello all, Considering the following code: var n = 42 let ptr1 = UnsafeMutablePointer(&n) let ptr2: UnsafeMutablePointer = UnsafeMutablePointer.init(&n) let ptr3 = UnsafeMutablePointer.init(&n) I get "Ambiguous use of init" for ptr3. There are no issues with ptr1 and ptr2. Is this a bug or am I

Re: [swift-users] Threads and weak references

2017-09-25 Thread Joe Groff via swift-users
> On Sep 22, 2017, at 2:38 AM, Howard Lovatt via swift-users > wrote: > > Hi, > > I was using a weak reference in a concurrent application and and the main > thread wasn't seeing an update to a class's property made by another thread. > If I replaced the weak reference with a closure, the p

[swift-users] NSRange error in docker

2017-09-25 Thread Barbara Reichart via swift-users
Hi, I am using swift in a docker container. Now I wanted to use NSRange, which according to the page is already fully implemented for linux. However when I try to use 'lowerBound' or 'upperBound' it gives me the following error: error: value of type 'NSRange' (aka '_NSRange') has no member 'lo