Hi Greg.
Thanks for the insight. In this case, I think I’m saved because I don’t
actually need to capture self in the block. I guess I was just too far along on
my train to realize that. I think this will work and it will keep the code
simple and neat.
I guess we'll see as I complete this
I know were you are coming from, but:
1. In other languages it would be the equivalent of an force unwrapped
optional and you could get a NullPointerException (or worse - core dump).
Using a force unwrapped optional just levels the playing field!
2. You could make it private(set) which would
> On Sep 25, 2017, at 6:12 PM, Kenny Leung via swift-users
> wrote:
>
> 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
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
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
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,
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