NullReferenceException: Object reference not set to an instance of an object StoredPref.retrieveData () (at Assets/StoredPref.cs:18)

Yesterday it work Fine But, when I open today this error popup.
“NullReferenceException: Object reference not set to an instance of an object
StoredPref.retrieveData () (at Assets/StoredPref.cs:18)”

here’s the script:

public class StoredPref : MonoBehaviour {

    VariablesTemp variablesTemp;

    void Start()
    {
        variablesTemp = GetComponent<VariablesTemp>();
    }

    public void retrieveData()
    {
        if (PlayerPrefs.HasKey("ShopCash"))
        {
            Debug.Log(PlayerPrefs.GetFloat("ShopCash"));
            Debug.Log(PlayerPrefs.GetFloat("TotalCash"));
            Debug.Log(PlayerPrefs.GetFloat("PersonalCash"));
            variablesTemp.ShopCash = PlayerPrefs.GetFloat("ShopCash");
            variablesTemp.TotalCash = PlayerPrefs.GetFloat("TotalCash");
            variablesTemp.PersonalCash = PlayerPrefs.GetFloat("PersonalCash");
        }
        else {
            PlayerPrefs.SetFloat("ShopCash", 0);
            PlayerPrefs.SetFloat("TotalCash", 0);
            PlayerPrefs.SetFloat("PersonalCash", 0);
        }
    }

Output is : 5 50 5

VariablesTemp script is attached to the same gameobject where StorePref is in.
and here VariablesTemp Script:

public class VariablesTemp : MonoBehaviour {

    public float TotalCash;
    public float ShopCash;
    public float PersonalCash;
}

is it PlayerPrefs or Variables that is giving me this error?

I found out variablesTemp.ShopCash is not accessible when I use this script

public class StoredPref : MonoBehaviour {

    VariablesTemp variablesTemp;

    void Start()
    {
        variablesTemp = GetComponent<VariablesTemp>();
    }

    public void retrieveData()
    {
        if (PlayerPrefs.HasKey("ShopCash"))
        {
            Debug.Log(variablesTemp.ShopCash);
            Debug.Log(PlayerPrefs.GetFloat("ShopCash"));
            Debug.Log(PlayerPrefs.GetFloat("TotalCash"));
            Debug.Log(PlayerPrefs.GetFloat("PersonalCash"));
            variablesTemp.ShopCash = PlayerPrefs.GetFloat("ShopCash");
            variablesTemp.TotalCash = PlayerPrefs.GetFloat("TotalCash");
            variablesTemp.PersonalCash = PlayerPrefs.GetFloat("PersonalCash");
        }
        else {
            PlayerPrefs.SetFloat("ShopCash", 0);
            PlayerPrefs.SetFloat("TotalCash", 0);
            PlayerPrefs.SetFloat("PersonalCash", 0);
        }
    }
}

but why so?

:: I think The Problem is variables in variablesTemp is still not loaded when the function retrieveData is called. This because When Variables are called a bit later it give value and not errors. How Can I call the function retrieveData after all variables are loaded?

:: I Finally FOund solution I just Added to the functions

if (variablesTemp == null)
            variablesTemp = GetComponent<VariablesTemp>();

and everything works fine
any better ideas Please post it here so I can deside which is better for my script.