ADC Home > Reference Library > Technical Q&As > Carbon > Human Interface Toolbox >

Multiple Resources with the Same Type and ID

Q I've been reading the documentation on Resource Manager and I can't seem to find an unequivocal statement about whether resource IDs should be unique within a given resource type within a given resource file. Some documentation seems to suggest it's OK to have duplicate resource IDs as long as my program doesn't expect to be able to find resources by ID later. What's the real story?

A You're right; during a recent extensive survey of our documentation (Inside Mac both old and new editions, Technotes, etc.), we found some discussions of resource IDs were less than perfectly clear on this topic.

The real story is that resource IDs should be unique within a given resource type within a given resource file. When you are adding resources to a resource file, you might want to use UniqueID and/or Unique1ID to help you find unique resource IDs.

However, some resource files do contain multiple resources with the same type and ID. This can be due to bugs in the program which created those files or it can be due to the aforementioned ambiguity in the documentation. When reading resource files your program did not create, make sure your program can gracefully handle such files.

Regardless of what you may read in other documentation, the Resource Manager in some versions of Mac OS may behave unpredictably when reading files with multiple resources with the same type and ID.

One easy way to detect whether a given file contains multiple resources with the same type and ID is to open the file with Resorcerer or ResEdit. These programs will warn you if they detect this condition.

[Nov 27 1996]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.