How to spawn one apple at a time

Hi, I am new to unity as a whole and decided to create small simple snake game as a test. I managed to create movement, the problem now is I want to eat the apple first, then wait till I eat the apple, then spawn a new one. So far I managed to make it wait till I eat the first apple but then it spawns a lot of apples all at once, how do I make it that It waits till I eat the apple then spawns one apple and then another apple so far and forth. Here is the code I got so far, I made only 1 apple spawn in a set location so far because I wanted to test it out before spawning in another location.

 void OnTriggerEnter2D(Collider2D other)
    {
        Destroy(gameObject);
    }
    public void checkApple()
    {

        
            if (GameObject.Find("Apple"))
            {
                Debug.Log("The apple has not been eaten");
            }

            else
            {
                Debug.Log("The apple has been eaten!");
                GameObject a = Instantiate(Apple) as GameObject;
                a.transform.position = new Vector2(-10.26f, 3.66f);
            }
        
                
    }

    void Update()
    {
        checkApple();
    }

Problem here is with the method you use to spawn new apples…

Checking on each frame if there’s an apple is not very performant, and the time it takes to create a new apple maybe is 2 or three frames, and the update method runs on those frames creating new ones…

Always use update to check something that changes overtime (like input or a timer) and not something that changes just a few times (like an event)

change the ontrigger enter method and use it inside the snake’s head… now add a tag to the apple (google unity tags if you don’t know what’s a tag) if the head enters an apple, destroy the apple and create a new one…

this code should be on the player head (the snake)

void OnTriggerEnter2D(Collider2D other)
{
    // if you hit something else that's not an apple it should not do this, so only spawn a new apple if the tag is correct
    if (other.gameObject.compareTag("apple"))
    {
        Destroy(other.gameObject);
        SpawnNewApple();
    }
}

i don’t use unity since a while so some methods might be wrong but i hope im clear enough to help you
Hope this works!