Thanks for your quick reply,
I want to use a label control to show the tag name of my sprite in the top left corner when I touch it , your code is only show the tag number, what I want to show here is "Sprite1Tag"
Thanks for your quick reply,
I want to use a label control to show the tag name of my sprite in the top left corner when I touch it , your code is only show the tag number, what I want to show here is "Sprite1Tag"
In this code, Spring1Tag is not an NSString. It's an identifier and it doesn't exist after your code is compiled. So there's nothing you can directly do to print that identifier when your program runs.
However there are other techniques for doing this. One technique is to maintain an array of the sprite name (as NSString objects) and then set the sprite's tag to be the index of the name in that array.
In this code, Spring1Tag is not an NSString. It's an identifier and it doesn't exist after your code is compiled. So there's nothing you can directly do to print that identifier when your program runs.
However there are other techniques for doing this. One technique is to maintain an array of the sprite name (as NSString objects) and then set the sprite's tag to be the index of the name in that array.
The problem with your post was that you took a well known problem of the C, C++, Objective-C, Java and other languages, and hid it away in a context with language that made it very hard to find out what you wanted. When you ask for help, remember that nobody can read your mind, so you have to pose your question in a very clear way. (BTW. Quite often that alone makes it unnecessary to ask).
I tend to write a class method "stringForTag🙁NSInteger)tag" which converts enum values to strings with a switch statement.