How to convert iOS game to unity and use the same load/save highscore files?

I’m converting iOS games from xcode c++ to unity c#. This is how I load and save my scores in xcode :-

void Load()
{
    NSUserDefaults *m_pPrefs = [NSUserDefaults standardUserDefaults];
    
    int nScore = 0;
    char szName = "Score";
    
    NSString *pName = [[NSString alloc] initWithUTF8String:szName];
    nScore = [m_pPrefs integerForKey:pName];
    [pName release];
}

How do I convert this code to unity c#, making sure all previous xcode versions of the games don’t lose their scores when updating to the new unity versions?

If I’m not wrong, PlayerPrefs on Unity iOS is a wrapper around NSUserDefaults, so you should be able to use this in Unity:

// The second parameter is the default value, if "Score" does not exist
int nScore = PlayerPrefs.GetInt("Score", 0);

Just try it on your device and see if it’s true.

As SkaredCreations answered, for SharedPreferences use PlayerPrefs. This works for all platforms including iOS and android.