Any better way to save a file/string on iOS for project to recall?

I know how to save parameter values using AudioProcessorValueTreeState::ParameterLayout

But what if I want to save a loaded file and some string for the DAW project, is there any way to achieve this? Do need to create a file which won’t get destroyed by closing the plugin? If so, what would be the best way to do it?

Thanks in advance!!!

AudioProcessorValueTreeState has a member called state. This is the ValueTree that it’s wrapping to do it’s thing. You can add entries to this ValueTree to do what you want. Just be aware that when you do this, there is nothing managing thread safety for you.

Thanks for reply, I already used the setProperty in state for saving the file name, what it lacks is a way to save a URL bookmark which is converted into string in object C in order to recall the local file.

I used this way to embed the object C functions according to this post:

But got no luck to retrieve the saved string, the AUv3 will crush on next time project opening.

Here’s my code for get and set state information:

void HelloSamplerAudioProcessor::getStateInformation (juce::MemoryBlock& destData)
    std::unique_ptr <juce::XmlElement> xml (mAPVTS.state.createXml());
    xml->setAttribute("pathURLBookmarkString", bookmarkEncoded);
    copyXmlToBinary(*xml, destData);   

void HelloSamplerAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
    std::unique_ptr <juce::XmlElement> xmlState (getXmlFromBinary(data, sizeInBytes));
    if (xmlState != nullptr)
            if (xmlState -> hasTagName(mAPVTS.state.getType()))
                juce::String bookmarkString = xmlState->getStringAttribute("pathURLBookmarkString", "");
                mAPVTS.state = juce::ValueTree::fromXml(*xmlState);
            auto filePath = mAPVTS.state.getProperty("currentFilePath", "").toString();
            auto filePathURL = juce::URL(filePath);
            HelloSamplerAudioProcessor::loadFile (filePathURL);
            juce::MemoryBlock bookmarkMemoryBlock;
            auto path = NSURLUtils::lastKnownPathFromBookmark(bookmarkMemoryBlock.getData());                
            auto url = NSURLUtils::URLfromBookmark(bookmarkMemoryBlock.getData());
            HelloSamplerAudioProcessor::loadFile (url);

Everything works fine on Mac and PC, but not the iOS .