I have
enum Colour {
white,
pink,
yellow,
blue
} Colour;
And I would like to do something like this:
for (int colour in Colour) {
// Do something here.
}
Can I do this and if yes, how?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An enum comes from, C while fast enumeration was an addition of Objective-C 2.0… They don’t work together.
An expression must conform to the NSFastEnumeration Protocol and be an Object! "elements" of an enum are not objects.
See Apple’s Fast Enumeration Documents for more information.
Check this example to see how fast enumeration works: