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);
#if !JUCE_IOS
auto filePath = mAPVTS.state.getProperty("currentFilePath", "").toString();
auto filePathURL = juce::URL(filePath);
HelloSamplerAudioProcessor::loadFile (filePathURL);
#else
juce::MemoryBlock bookmarkMemoryBlock;
bookmarkMemoryBlock.fromBase64Encoding(bookmarkString);
auto path = NSURLUtils::lastKnownPathFromBookmark(bookmarkMemoryBlock.getData());
auto url = NSURLUtils::URLfromBookmark(bookmarkMemoryBlock.getData());
HelloSamplerAudioProcessor::loadFile (url);
#endif
}
}
}
Everything works fine on Mac and PC, but not the iOS .