TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Structuring Modern Objective-C

17 pointsby AshFurrowover 11 years ago

3 comments

programover 11 years ago
Enable modules and use them to import system frameworks:<p><pre><code> &#x2F;&#x2F; #import &lt;Cocoa&#x2F;Cocoa.h&gt; @import Cocoa; </code></pre> Use literals and subscripting methods:<p><pre><code> NSNumber *yes = @YES; NSNumber *number = @42; NSArray *array = @[@&quot;Hello&quot;, @&quot;World&quot;]; NSDictionary *dictionary = @{ @&quot;name&quot; : NSUserName() }; </code></pre> Learn about &quot;instancetype&quot;: <a href="http://clang.llvm.org/docs/LanguageExtensions.html#objective-c-features" rel="nofollow">http:&#x2F;&#x2F;clang.llvm.org&#x2F;docs&#x2F;LanguageExtensions.html#objective...</a><p>Always use NS_ENUM and NS_OPTIONS to declare enum types:<p><pre><code> typedef NS_ENUM(NSInteger, HNExample) { HNExampleDefault, HNExample1, HNExample2 };</code></pre>
评论 #7094569 未加载
liviuover 11 years ago
Thank you Ash, I was looking for that for long time.<p>I&#x27;m happy that I found your blog with so many iOS resources. I&#x27;ll read them all and I&#x27;ll follow your activity a there.
anon1385over 11 years ago
&gt;Instead, you should be declaring them as properties, and then accessing them through message-passing or dot syntax.<p>Dot syntax <i>is</i> message passing. This type of confusion is one of the reasons I really hate dot syntax.
评论 #7094565 未加载