We have a fireside apple tree that produces lots of apples every year. The apples were almost useless because they were always full of worms. I had tried the fruit tree sprays, but the flies and worms would still get worse every year. I also hung plastic apples with a sticky gunk on them on the tree this caught plenty of flies but the fruit was still all full of worms.
I then read about a Japanese solution, where they wrap each apple in a bag just after the blossoms finish. I got some twist tie sandwich bags and put one over each of several dozen apples. I cut the bottom corners of the bags to let water drain out.
I had, however, not planned for another pest, the deer. They stripped all the apples I had wrapped that were within their reach, off the lower branches of the tree, and used their hooves to free the apples from the bags. They would then take one bite out of the apple and go on to the next one. However, the few apples that did survive were perfect, with no worms. This encouraged me, and the next year I wrapped several dozen apples again and also put up a temporary fence around the tree.
This successfully prevented the flies and the deer, but I was defeated by another pest, that had an appetite for apples, the squirrels. They were worse than the deer because they could climb the tree and reach all of the apples I had wrapped. That year they left me but two apples. The rest they knocked on the ground, clawed off the plastic bag, took one bite, and left the rest to rot.
I am a bit stubborn and was not about to let some squirrels defeat me. I reasoned that as a human I should be able to outsmart the squirrels. If you have ever had a bird feeder, you know that squirrels are very clever and persistent when it comes to getting access to food, so they are quite formidable opponents. I went to a pet store and got a couple of large Elizabethan collars. I put them around the trunk, below the lowest branches. That worked. That year I had my best crop of apples ever. I still lose some to wind and rain storms and other events, but most survive to harvest. Since these are fireside apples, they ripen late in the season, in October, so I have to monitor them well into the fall.