new to Cocoa/Objective-c: many points of confusion
new to Cocoa/Objective-c: many points of confusion
- Subject: new to Cocoa/Objective-c: many points of confusion
- From: Alex Hall <email@hidden>
- Date: Tue, 22 Jan 2013 01:10:28 -0500
Hello all,
First, I will quickly give my background. I graduated two years ago with a computer science degree and a math minor; my education focused mostly on Java, Python, and some web languages, with bits of several other languages thrown in from time to time. I understand the concepts of modern programming (methods, classes, objects, inheritance, all that) quite well thanks to that degree, but we never delved much into C-style languages. Now, I am trying to teach myself Objective-c, with the goal of writing some Mac and/or iOS apps (Mac ones first). I should also say that I am blind, relying on Apple's Voiceover screen reader to use my mac and iPhone. As of right now, making connections in IB is basically inaccessible to Voiceover; I can lay out my UI, but not connect anything to code, so I am working on understanding the theory at this point until Apple fixes IB.
For what it is worth, my eventual goal is to release some common games for Apple devices that are currently ubiquitous, such as Solitaire, but that have no blind-accessible versions in either App Store (imagine no Solitaire on your iPhone!). For the purposes of learning, though, I am trying to work through Apple's Trackmix example, while learning OpenAL on the side and having a peek at how to write a synthesizer plugin using Apples Morse Synthesizer as a reference. My main focus, of course, is on the Trackmix tutorial and on learning the concepts behind it, though the afore-mentioned limitations of IB have me stuck for now.
Now that that's done, let's get started. I apologize in advance if any of the below are considered off-topic for this list. Please let me know which of my questions belong on another list and I will take them there instead.
*delegates: my understanding is that these take the place of subclasses (though why this is useful is beyond me), overriding methods they are designed to handle rather than letting the base class take those methods. However, I not only don't see why this is so great, but I don't understand the syntax used to declare them or attach them to other classes so the delegates' methods get called when any of those methods are called on the object to which the delegate is attached. Every example I have found seems to indicate they are used only for GUIs, but Apples docs say that they are a much more general-purpose system?
*Speaking of delegates, I don't follow the syntax used to set them up. Every example seems to love to use views or other UI examples, which would be fine if I could follow that, but I'm not that advanced yet. A more basic, even if not-so-useful-in-reality, example would be very much appreciated.
*Outlets: I have a basic idea that these are a way of sending messages from object to object, a bit like listeners. However, I don't really understand the syntax used to make them. Moreover, I always see them used in GUIs, but Xcode's Interface Builder won't let Voiceover users make connections, so I can't proceed with Apple's tutorials on this topic. Somehow, these connections are outlets, or are related to outlets, or some connections are outlets, or something... Anyway, as I can't make the connections to get an idea of how they work, I'm trying to follow others' examples which I don't get as they use code I didn't write and that makes no sense to my newbie brain. So, what exactly is an outlet and how and why would I set one up? Again, a very basic code example would really help here.
*Every so often I'll see a class between less- and greater-than signs when an example talks about a delegate, but I don't know what this is for. What does it mean to put these symbols around a class (or maybe they are around an object?)?
*I've seen sample code that seems to go against everything I know about method calls:
-(IBAction) someObject:(id)inSender;
Huh? Is the (IBAction) casting, or a method call, or what (I understand what IBAction is, but not why it is where it is and in parentheses)? I know why the "id" is there, so this action will work with any UI element, but why the colon? What is inSender doing there, hanging out at the end of the line? How does the method (in the m file) have any idea what inSender is as it appears to not be an argument? Why does it need inSender if it already has the id argument?
*What is a property? I see these used a lot, but I'm not clear on what they are compared to, say, class-level variables or methods. The statement I'm talking about is the "@property" statement.
*I know that using the @synthesize statement auto-generates getters and setters, but no one ever talks about how to use them once they are set up. That is, what is the syntax for these generated methods? I assume it is "get" and "set", cammel-cased with the variable being synthesized (and with a single parameter matching the variable type in the case of the setter) but I want to be sure.
Thanks in advance for any information. Oh, and yes, I have already researched all this thoroughly, having spent the last couple days reading every blog, article, apple doc, and forum I can find, but the above seem to be sticking points for some reason. I have no idea why I can't seem to get past these, but several concepts seem to be so important and oft-used that I am hopeful I will be able to move forward much more smoothly once I have them under my belt.
Have a great day,
Alex (msg sent from Mac Mini)
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden