Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
XCode enum help
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Raconteur" data-source="post: 1064753" data-attributes="member: 147076"><p>Hi all,</p><p></p><p>Not sure if this is the proper place for these questions, but I have gotten great help here in the past and thought I'd try.</p><p></p><p>I am having a hard time with declaring and using enums in my XCode project.</p><p></p><p>My declaration is going in the .h file, just above the @implementation line:</p><p>[CODE]</p><p>typedef enum {</p><p> EASY,</p><p> NORMAL,</p><p> HARD</p><p>} DifficultyLevel</p><p>[/CODE]</p><p></p><p>That compiles just fine. But when I try to access it in an instance method within the .m file:</p><p>[CODE]</p><p>switch ([self difficultyLevel]) {</p><p> case DifficultyLevel.EASY:</p><p> ...</p><p>}</p><p>[/CODE]</p><p></p><p>I don't get CodeSense, and get errors. I am obviously not doing this properly, but I cannot find a reference on HOW to do it.</p><p></p><p>Can someone guide me?</p><p></p><p>Cheers,</p><p></p><p>Chris</p></blockquote><p></p>
[QUOTE="Raconteur, post: 1064753, member: 147076"] Hi all, Not sure if this is the proper place for these questions, but I have gotten great help here in the past and thought I'd try. I am having a hard time with declaring and using enums in my XCode project. My declaration is going in the .h file, just above the @implementation line: [CODE] typedef enum { EASY, NORMAL, HARD } DifficultyLevel [/CODE] That compiles just fine. But when I try to access it in an instance method within the .m file: [CODE] switch ([self difficultyLevel]) { case DifficultyLevel.EASY: ... } [/CODE] I don't get CodeSense, and get errors. I am obviously not doing this properly, but I cannot find a reference on HOW to do it. Can someone guide me? Cheers, Chris [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
XCode enum help
Top