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 trialSolona Armstrong
643 PointsObjective C: Lingering Questions
There are some concepts I still don't understand after doing the "Build a Simple iPhone App" project.
What is the difference between a method and a property? My understanding is that a property is an "adjective" and a method is a "verb". In other words, a property is static and a method does something?? Why do properties have methods? Aren't they qualifiers of classes? (I'm a bit muddled).
When do I use a '-' at the beginning of the line?
Video: Creating a Property
What are setter and getter methods? Are they inherent to Objective C? Or something you declare? When would I use them? The video kind of glosses over them.
What is @synthesize? I get that they imply getter and setter methods and create the "underlying instance variable", but I don't understand what this actually means.
How do I know when to use 'self.' and when not to use it?
I don't fully understand the concepts of properties and methods within classes. Not enough to move forward on my own.
Video: Programming a Background Image
I'm not 100% clear on viewDidLoad. How do I know when to put code in there, rather than somewhere else?
-
In the line of code
UIImageView *imageView = [UIImageView alloc]
What parts are inherent to Objective C and what parts am I inventing?
General
- I'm not clear on how to read the documentation. How do I know which parts are methods and which parts are properties? Where is the syntax given?
20 Answers
J V
1,774 PointsYou will not learn everything in one website. We will need several websites, books, and mentors throughout our coding journey. I found the classes very clear to me. If, I had a question I'll just post here or look around on the web. I want to share this URL with everyone: http://m.cacm.acm.org/blogs/blog-cacm/156836-teaching-programming-to-a-highly-motivated-beginner/fulltext
J V
1,774 PointsWhat is a method? A method is a particular function.
What is property? It's a place store the function data. Please check this to become more clear http://developer.apple.com/library/mac/ipad/#documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html
Jonathan Scheel
5,531 PointsI'm right there with you. I'm almost completely done with the "Build a Simple iPhone App" lessons and feel like I haven't learned anything but how to mimic what Amit is doing... and most of the time not even that. I don't understand the reasons why we are doing what we are doing and what it all means.
J V
1,774 PointsI took the same course. I did my personal search online and I read a book aligned with the course. Also, when you take the other courses on iOS some of your questions will be answered. Please don't expect you will get all the answers on this site but this a a great start to your coding journey.
Sebastian Nitu
8,616 PointsIn an abstract way if you view an Object as, for example a Plane, then a method will be actions that can be applied on that plane.
Example: takeOf(), landPlane(),
Given the example above, properties are nothing more than, well, properties (in an abstract manner) of that plane.
For example, an Airbus A380 object would have flaps of X width and Y height, wings of X width and Y heights, 3 doors etc and all of the methods from the above example can be applied to this object: takeOff(); landPlane();
Hope I got this right and if so, I hope it helps you better understand.
Solona Armstrong
643 PointsThanks for all the answers!
Jonathan Scheel I feel the same way. I'm a bit disappointed about joining this site after going through the first project. There are only two iOS projects and I'm already into the second without truly understanding what I'm doing. As you say, I'm mimicking Amit.
I play some videos over and over to listen to him explaining the concepts. But, rattling off concepts "we apply this method to that class" does nothing to help it sink in, for me.
J V Thanks for the link. The intro videos to this site claim that a non-developer can use this and become a pro. If I need to read documentation elsewhere, just to understand what I'm learning here, then these claims are misleading. I'm not at all averse to reading documentation, but I often don't understand it and need a guide to decipher it for me.
Is a class in iOS the same as a function in Javascript or PHP?
Paul Cisneros
1,332 PointsAlthough, you may feel like you aren't learning anything, you are. Your mind is absorbing it, but you are not yet fully conscious of it yet. If you persist, you eventually will. This applies to all forms of learning.
A good example may be learning a new language. I lived in the Czech Republic for 2 years. The first year, I was very frustrated and felt like I couldn't learn the language (Czech). Then after a year, it seemed like one day I could hold simple conversations, order food at restaurants and was able to read Czech as well. It may have seemed like it was an overnight transformation, but in reality, it was a gradual one.
That being said, the concepts behind programming aren't immediately easy to grasp. I'm actually in the same boat as you guys as I myself haven't grasped the concepts yet, however, I understand a lot more than I would have if I had taken this course or any Objective-C course even one year ago. That's because my programming chops are much better than a year ago.
My advice is not to rely on TeamTreehouse to teach you everything. Try to learn from everywhere you can. The best way to learn how to build apps is to start building your own using apps and code that have been open sourced on GitHub (or other places as well). Use Stack Overflow.
I think their first Crystal Ball app is a perfect introduction. If you are having trouble with it then I'd go through the lesson again. Go through all the source code and become acquainted with it. Apps can get a lot more complicated than this example.
Good luck and don't give up! ; )
Jonathan Scheel
5,531 PointsI agree, Solona. I was extremely confused as to why Amit was constantly referring to the Apple Documentation, when the other courses are take you aside and teach it to you without using the documentation as a crutch.
With the HTML and CSS courses, it does mention the W3C website frequently, but only as a follow-up to learn more information about the concept which is fully discussed in the video lessons.
In the iOS videos, the documentation is used as the lesson itself, and the video just shows you how to access it with the "option-click" in XCode.
I didn't want to say or admit it, but I would agree with you the their claims are misleading in regards to the iOS lessons being able to take a beginner to a pro. I'm hoping they improve there iOS courses soon, but I don't see any such plans on their content roadmap at this time. :(
Solona Armstrong
643 PointsI have hope that maybe Amit Bijlani can answer these fundamental questions properly in the Forum. I'm sure, as their membership goes up, they will start filling in the gaps in their lessons.
Solona Armstrong
643 PointsLynda.com's Essential Training in Objective C is more comprehensive and clear. http://www.lynda.com/Xcode-4-tutorials/Objective-C-Essential-Training/77860-2.html
Jonathan Scheel
5,531 PointsThanks, Solona Armstrong . I'll have to check that out.
Sebastian Nitu
8,616 PointsI honestly hope I am not doing something wrong here but here's how I've managed to combine stuff:
Unfortunately I have to agree that the iOS classes are somewhat under developed for the newcomer. If you would go for a straight comparison between the JavaScrip classes and the iOS classes I would say that even though it is clear that Treehouse tries to lower the learning curve they haven't exactly found the best way (so far!).
For now, even though I love Treehouse and I will keep my subscription active, for iOS references and classes I actually take a whole other class at Xcelme.com and then come back to Treehouse and try to understand what Amit Bijlani is teaching.
I honestly hope that Amit Bijlani and the rest of this great team manage to find a better way to teach these classes and maybe streamline or spinoff the whole curriculum.
J V
1,774 PointsIn between if you have any questions or want to collaborate can contact me directly at Skype: t170neva.
Jonathan Scheel
5,531 PointsJ V , I tend to think that while it may be true we can't learn everything in one website, Treehouse could certainly do a better job at teaching the basic concepts which seem that be lost in the iOS lessons. Surely these lessons could be enhanced and provide much more of a beginner's viewpoint than they do currently. instead we seem to jump straight into coding without learning the structure of the files we're manipulating.
Also, I doubt Treehouse itself would agree that you can't learn everything you need to know from one website... as that is one of their major selling points... being able to take a beginner and have them become a pro.
J V
1,774 PointsI came in to this website as a total newbie. I never thought I would ever do any coding in my life. I got inspired through life experiences. I was told by many that treehouse is a great site. Plus the first time I heard treehouse was through the CEO talking on a site called Mixergy. I thought it was good idea. Last month, I decided to give it a try. I thought this site was good at giving little info and not getting me confuse. It's hard to think like a programmer and understand how some things should be done. If this site didn't make the videos interesting and giving little info at a time. I think I would've quit. Every project and deep dive gives more info to the student.
Jonathan Scheel
5,531 PointsOh I agree entirely. I'm a seasoned web developer and yet I still learned a few tricks on the Deep Dives on the Web Developer side of things. But that actually highlights the point that there are no Deep Dives that do this on the iOS courses. If those were available, and they took you through the more basic fundamentals of Objective-C and XCode, I doubt I would be confused at all. It just seems those fundamental lessons are missing right now.
Instead the Deep Dive available actually jumps right into even more advanced stages such as ARC, Notifications, API Access, and Location frameworks.
I'd love to hear from someone at Treehouse regarding the future plans for the iOS section, since it doesn't appear to be on their current content roadmap.
J V
1,774 PointsI agree! Once I finish the iOS videos and challenges/quizs. If here no new courses for iOS. I am leaving the website.
This maybe useful: http://teamtreehouse.com/library/ios-development/ios-foundations
Solona Armstrong
643 PointsYup, if their selling point is that they will take you from noob to pro, then that's what I expect...
I'm really hoping Amit Bijlani will chime in here and answer some of these fundamental questions.
J V
1,774 PointsIt's holiday, He's most likely off. You might have to wait for another day.
Jonathan Scheel
5,531 PointsI sent an email in to Treehouse Support (which is probably closed today for Memorial Day) asking what the plans were for future course developement on the iOS projects. I'll let you know when I hear back.
Amit Bijlani
Treehouse Guest TeacherReally appreciate all the feedback, as these are all valid concerns. We are working on an Objective-C foundations course and another course that picks up where the "Blog Reader" project leaves off. So if there is anything you would like us to teach in either of these courses then do let us know.
"Build a Simple Blog Reader" was never meant to be an end all be all course. It's simply there to get you oriented with the tools and the language. My approach was to get you acting and reacting to code as soon as you can. Only when you see the effects of your code on the screen can you connect the dots. The "Blog Reader" course goes deeper into the language and design patterns. As I mentioned, we are aware of the holes in our curriculum and are working on it. We always welcome feedback because it helps us improve and serve you better.
To address Solona Armstrong's questions:
- What is the difference between a method and a property?
A method defines an action and a property defines an attribute. For example, you have a class called BlogPost
a property of a BlogPost
class would be Title
, Author
,Read
. A method on a BlogPost
class would be markAsRead
where the method flags the Read
property to YES
.
- When do I use a '-' at the beginning of the line?
When you are defining a method.
All your questions related to properties and method are answered in the Data Modeling stage. You can also check out Apple's Objective-C Primer
I'm not 100% clear on
viewDidLoad
How do I know when to put code in there, rather than somewhere else?
If you have written any Javascript or jQuery then think of viewDidLoad
as the $( document ).ready
. As the name suggests it is an event override provided by the view controller to act upon the view once it has been loaded by the storyboard. Any initialization of variables or additions to the view go in the viewDidLoad
method.
- In the line of code?
UIImageView *imageView = [UIImageView alloc]
What parts are inherent to Objective C and what parts am I inventing?
Instance variable
defined by you
|
UIImageView *imageView = [UIImageView alloc]
| |
Class provided Allocating a new instance of class UIImageView
by UIKit framework
// In javascript this would look something like:
var imageView = new UIImageView();
- I'm not clear on how to read the documentation. How do I know which parts are methods and which parts are properties? Where is the syntax given?
The Apple documentation for a particular class only states the methods and properties of that class. If you are looking to learn how to use that class then you have to read the guides or look at their Sample Code.
Happy to answer any more questions or doubts.