# Question according to closures and releasing variables

**URL:** <https://forums.swift.org/t/question-according-to-closures-and-releasing-variables/63387>\
**Category:** Using Swift\
**Tags:** av-foundation\
**Created:** [February 27, 2023, 11:13am UTC](https://forums.swift.org/t/question-according-to-closures-and-releasing-variables/63387 "2023-02-27T11:13:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lupurus](https://avatars.discourse-cdn.com/v4/letter/l/e274bd/32.png) [@Lupurus](https://forums.swift.org/u/Lupurus)\
**Post date:** [February 27, 2023, 11:13am UTC](https://forums.swift.org/t/question-according-to-closures-and-releasing-variables/63387/1 "2023-02-27T11:13:07Z")

</div>

I have some issues with converting a mp3 file to m4a using AVFoundation. I created a topic in stackoverflow here:

> <https://stackoverflow.com/questions/75578403/error-convertig-mp3-to-aac-audio-with-avfoundation>

I now figured out the solution and I slightly think, what's going on under the hood. But what I am asking for now is if I understand it right and if there is another solution.

So the solution is, that I have to make `assetReader` and `assetReaderOutput` as instance variables, because when the `assetWriterInput.requestMediaDataWhenReady`-closure starts, the conversion function will end and both variables will be released. Is that correct? And if so, is it necessary to make instance variables or can I tell the compiler to retain those values?
