# Problem loading a preset for an AUV3 plugin on iOS

**URL:** <https://forum.juce.com/t/problem-loading-a-preset-for-an-auv3-plugin-on-ios/35782>\
**Category:** MacOSX and iOS\
**Created:** [October 21, 2019, 8:29am UTC](https://forum.juce.com/t/problem-loading-a-preset-for-an-auv3-plugin-on-ios/35782 "2019-10-21T08:29:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mttc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mttc/32/1985_2.png) [@mttc](https://forum.juce.com/u/mttc)\
**Post date:** [October 21, 2019, 8:29am UTC](https://forum.juce.com/t/problem-loading-a-preset-for-an-auv3-plugin-on-ios/35782/1 "2019-10-21T08:29:53Z")

</div>

Hi, it seems that calling `setProgram(int)` to load a plugin’s preset from a host app doesn’t work on iOS.

The current code builds the **AUPreset** struct populating only the preset number, using an empty string for the name.

```
void setCurrentProgram (int newIndex) override
{
    AUPreset current;
    current.presetNumber = newIndex;
    current.presetName = CFSTR("");

    AudioUnitSetProperty (audioUnit, kAudioUnitProperty_PresentPreset,
                          kAudioUnitScope_Global, 0, &current, sizeof (AUPreset));

    sendAllParametersChangedEvents();
}

```

Populating correctly also the corresponding preset name works fine, for example:

```
void setCurrentProgram (int newIndex) override
{
    AUPreset current;
    current.presetNumber = newIndex;
    
    CFArrayRef presets;
    UInt32 sz = sizeof (CFArrayRef);

    if (AudioUnitGetProperty (audioUnit, kAudioUnitProperty_FactoryPresets,
                              kAudioUnitScope_Global, 0, &presets, &sz) == noErr)
    {
        if (const AUPreset* p = (const AUPreset*) CFArrayGetValueAtIndex (presets, newIndex))
        {
            current.presetName = p->presetName;
        }
        CFRelease(presets);
    }

    
    AudioUnitSetProperty (audioUnit, kAudioUnitProperty_PresentPreset,
                          kAudioUnitScope_Global, 0, &current, sizeof (AUPreset));
    
    sendAllParametersChangedEvents();
}
```

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [December 18, 2019, 6:22pm UTC](https://forum.juce.com/t/problem-loading-a-preset-for-an-auv3-plugin-on-ios/35782/2 "2019-12-18T18:22:28Z")

</div>

Thank you for reporting.

> <https://github.com/WeAreROLI/JUCE/commit/a268860713ba78f67f23da943aacf81fd3b846f4>
