How do I wait for an object to load before accessing it's information?

Hi,

I’m building an iOS game that requires items to be generated dynamically, it then looks in a folder hierarchy after a corresponding file which has the item’s name and icon.

Since in some cases I need to access the item’s information straight away I’m getting null pointers because the item I’m trying to access hasn’t loaded / generated all it’s information yet (loading from resource folder). For example: Loading items to Inventory at start and having labels with it’s name, where I get an error because the name isn’t available yet.

This is a problem I’ve stumbled upon a few times before in other project but somehow found a way around it. In this case I’d like some help figuring out what the proper way of doing this is. Unfortunately loading all items at the start isn’t really an option.

Apologies if this has been answered before, my search skills must be lacking :slight_smile:

Grateful for any help, thanks!

Phil

Maybe perform a yield/coroutine and have it run a function to gather all the information first. Then it will continue and shouldn’t have any null pointers. Just my thoughts…

This page may also be of help