Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Weather App with Swift (Retired) Concurrency Using Our JSON Data

Do I need to know NS/Cocoa stuff for this course?

When Pasan talking about NS Dictionary and Swift Dictionary, I googled NS because I had no idea what that was.

Then I found an answer on StackOverflow: http://stackoverflow.com/questions/473758/what-does-the-ns-prefix-mean

I have no background in Objective-C/Cocoa/Swift, so I am a little overwhelmed to know that there are a lot more NS stuff and they are probably very important.


Do I need to know NS/Cocoa? Are they relevant for foreseeable future? How/where can I learn them for iOS development?

What specific questions do you have?

I updated the question.

Pasan Premaratne will be able to let you know exactly what will be helpful to know.

2 Answers

Pasan Premaratne
Pasan Premaratne
Treehouse Teacher

Jamie Fang,

You're quite ahead of the curve here :) The NS legacy is quite important and our plan is to teach it as we go along. That's a ways away though so here's a summarized intro:

NS comes from NeXT*S*tep, an operating system that Apple purchased back in the day and folded into their products. The underlying frameworks that we use to build Mac and iOS apps are known as Cocoa and Cocoa Touch respectively and are built on top of the NeXTStep Foundation and AppKit libraries.

Objective-C, the other language for iOS development, and the language that NeXTStep is built in, is built on top of the C language. So when the NeXTStep engineers were creating the base classes for Cocoa/Cocoa Touch, they needed to add a unique prefix to the objects they created so that it wouldn't conflict with C or Objective-C objects; they chose to add the NS prefix. So that's where NS comes from.

Cocoa and Cocoa Touch, the underlying frameworks for Mac/iOS development, are built in Objective-C, so even though we use Swift to write apps, we're using the same underlying framework and end up using Objective-C objects. Apple has done some work under the hood so that your Swift code works automagically-ish with the Objective-C objects so you don't have to worry about writing any Objective-C code for now.

To answer your questions:

  1. Yes, you need to know about Cocoa and it's classes. I'll teach you what you need to know in each course though and eventually, we'll start writing some Objective-C code as well. If you want to get started immediately, we have a separate track - iOS Development with Objective-C that mirrors the Swift track so you can learn in either language.

  2. Cocoa and thereby all the NS classes are extremely relevant since iOS is built on top of it. There are some interesting opinions out there about its longevity but it's too early to comment on those things really. For now, Cocoa is all we have.

  3. If you want to know the ins and outs, I'd recommend starting with the Objective-C track and then making your way over to Swift when you're comfortable. All the code out there related to iOS development, whether it's blog posts, 3rd party libraries, etc, are almost all in Objective-C so you will certainly have more resources to fall back on.

Hope this helps.

Thank you so much! This is very helpful!

Brice Amram
Brice Amram
2,937 Points

Pasan, I was just browsing the forum for this video and thought the question from Jamie was quite interesting. Just to thank you for your detailed answer. Like the different courses it is very clear and, although it deals with high level concepts, it is very useful I think because it helps a beginner like me to bring pieces of the puzzle together ( "Cocoa", "NS", etc).

Is there a place, within Treehouse or not, with some similar easy-to-understand-yet-fundamental explanations about the overall environment ?


Pasan Premaratne
Pasan Premaratne
Treehouse Teacher

Brice Amram,

We don't really have such plans to be honest but I certainly think it would be worth talking about some history and legacy in our videos to paint a better picture.

We'll be redoing the Objective-C content quite soon and I'll take this into account :)

Brice Amram
Brice Amram
2,937 Points

Hi Pasan Thanks for the feedback.