Fundamental Architecture of an iPhone App: what does exactly happen? - objective-c

I am new to iPhone-Programming and I am probably asking a beginner's question, but I really couldn't find a satisfying answer to this:
I would like to understand the underlying architecture or structure of an iPhone App. What comes first, what are the parts that a starting template usually does automatically? In C-Programms, you know the program always jumps into main and then everything starts like you coded it. In iPhone-Programming, we start also in main and then something like the event loop starts and etc.there is a lot going on under hood, which I would like to understand so I feel more confident writing code and actually being aware of all consequences that my code causes.
I would be happy about any answers or are there any good references that are compact and only focussed on the coding architecture?

Read this for example ... http://www.technolike.com/archives/86/core-application-architecture-for-iphone.html ... and Google for more. There are many resources how to iPhone application starts, what's going under the hood, how event handling cycle does work, etc. Also when you read these resources, try to ask more specific questions. It's too broad question to answer everything.

I suggest that you browse through Apple's documentation on iOS development: http://developer.apple.com/library/ios/navigation/
If you want to learn the low level stuff first, perhaps you should look into how Objective C works and then move to learn about UIKit (which is the central framework/library for iOS app development).

Related

gamesalad to unity3D?

I'm a newer than new newbie ... and I think this question should be part of the thread Newbie - Game Development (iPhone) - New to Objective C and Game Dev but I could only find an "answer" post window. I'd like to ask a related question.
If I were to develop a game in GameSalad or Stencyl, would I be able to look at the actual code of that creation and maybe import it into something more complicated like Cocos2d-x or Unity3D later on?
I ask, because happybadgers advised in that above mentioned question/answer to start out in something like GameSalad -- sort of jump into creating a game while learning objective c. But I imagine a person would eventually want to do more than "drag and drop" coding as their skills increased ... so -- could you take your drag and drop creation(s) and pop it/them into something that lets you play with the code more?
I'm aware that this may be a stupid, naive or stupidly naive question, so please excuse me, if so.
Thank you for your time. And if you vote to boot this question, I hope you'll explain the error of my ways.
As far as I know you cannot view the code directly in Gamesalad. However, a lot of the logic behind the game will be easy to replicate in code once you get the hang of it.
An example of this is the statements that you use such as if, while, for, get and set will all be available in Unityscript. You will not be able to convert your game into a Unity file however the art assets will be transferable.(So basically you can keep the aesthetic of your game,but you will just need to translate the drag and drop to code.)
Good luck,
p.s
(If you are really struggling with some code, just send me the drag and drop logic and I will do my best to convert it for you).

Requirements for learning Cocos2D?

I would like to make a 2D iPhone game, I've done some research and Cocos2D does seem like the best option, I am just wondering how much knowledge of Objective-C I will need before tackling Cocos2D. I know the fundamentals of programming in Objective-C - I can make a basic command line tool app. I've done some iOS SDK tutorials but I wouldn't know how to make an iOS app if I was asked because the tutorials I'm currently following are about three years old.
What is required as prior learning before using Cocos2D and does anyone know of any good resources? I'm more of a visual learner so I find videos more helpful than books or blog posts.
Thank you in advance for your time and any help :)
There is no required prior learning. Use it. If you get stuck on something, look it up, google it, or ask a question.
Meaning: don't waste your time learning general concepts without actually being in the situation of having to apply them.
Analogy: you don't need a PhD in mechanical engineering to drive a car - though it might help when you run into any issues. But in such a case just do what 99% of all people do: call for help. It hardly makes any sense to first learn the potential problems you can have with a car, you deal with them as they happen.
Also: frustration is part of the game and can not be avoided. :)
how much knowledge of Objective-C I will need
A lot. You need to master Objective-C before trying to make a bigger project like this.
And to understand Objective-C, you need to have a very solid knowledge of C.
(Also, for using 3rd-party frameworks lile Cocos2D, make sure you understand well the basic, default libraries such as Foundation and UIKit.)
For making games like Free flow , having an intermediate knowledge of Objective-C is sufficient. But if you plan on make something like Temple Run, then you need really good knowledge of Objective -C,Open-Gl and cocos2d..
The site I would recommend is raywenderlich.com, that's where i started from and they have tutorials from really basic level to really advanced level.
Hope this helps
The answer to that depends truly on who you are, your work ethics, and how much effort your are ready to consent to that effort. I would argue that if you have solid foundations with other OO language/frameworks, your quest is possible. I would start by 'repurposing' a freely available game ( you will find many good examples and tutorials from Ray Wenderlich and also Steffen Itterheim. Pick a sample project that is not too 'distant' from your game specification, and repurpose it. In doing so, you will break-in to objective-C and some of the basic frameworks you need to comprehend. Mastery will follow if you are dedicated and stick to it. Also, SO rules : many answers are available here : appropriate questions will yield many helpful hints and solutions to point problems.
ps. My biggest learning curve turned out to be xCode, a truly arcane and dogma-ladden IDE. I since switched to another IDE and my productivity has gone back to respectable levels.
I recently picked up Objective-C and cocos2d at the same time. I did a lot of reading about objective-c in the beginning to give me a primer. Aside from the syntax, most of that knowledge remains unused in my game. The most important things to learn about objective-c before starting in on cocos2d tutorials are, memory management, and debugging.
The reference count memory management might take a minute to get used to depending on what languages you are coming from. The general rule is, if you alloced/copied (without autorelease) or retained it, you must at some point release it, and if you need to use something beyond the current scope, you should retain it. You can see from some cocos2d examples of overwriting an objects dealloc method in order to dealloc anything you created/retained.
The debugging took me a minute to get used to as well. It helps if you add a high level try/catch block that you can use to log uncaught exceptions, otherwise some of your errors will give you little info to go on. You may also want to research/mess with some of your project settings to allow for better bug catching, such as enabling zombies. A big causer of crashes in objective-c is sending messages to already dealloced objects. Once you come across a badaccess error that you can't figure out, you will basically be forced to get knee deep in this stuff in order to figure out the cause.
Some other purely objective-c knowledge that will come in handy are getting very familiar with how NSArray and NSDictionary objects work, how they automatically retain/release, and how they can only hold objects (no primitive values). To work with floats/int and arrays/dictionaries, you need to convert primitives into something like an NSNumber object, which can be done fairly easily with a little research. Another helpful too is knowing how to save/load plists. There are convenience methods for doing this on NSArray and NSDictionary objects. This along with a little knowledge of the NSFileManager should be enough to help you save/load game states. If you want to get really fancy/clean in your coding, you will also learn about observers in objective-c. KVO can be great for making your UI update automatically on a certain objects property changes. For instance, my HUD KVOs the player object's life, so that when the life value changes, the HUD automatically updates. This can allow you to make a cleaner MVC type application. You can also register to listen to other types of messages (not just property changes), just make sure to unregister your listeners when you are done listening.
My last bit of advice would be to always pay attention to XCode warnings. If you are getting one, and you don't know why, you should figure out why. Some simple ones you might be able to ignore, others may cause bugs that you will not be able to track down any other way. For instance, I once used the function max() in my code, and xcode gave me a strange warning that I didn't understand. This caused havoc on my program by corrupting the stack. When I changed max() to MAX(), three or four unexplained bugs instantly disappeared. This kind of thing can set you back weeks, and take serious combing through every piece of your code if you don't catch it right away.
The rest can mostly be learned by looking at cocos2d code/examples. Good luck.

Sencha touch app building

I was put in charge of learning this and well I have read and tried to understand it all. I am lost in how to get it started and optimized. I need to achieve a window at startup that is menu based and takes you to different components. I think I have the photo galleries sorted out just now sure how to link to the startup window.
examples
I used this tutorial when I was trying to learn - http://miamicoder.com/2011/writing-a-sencha-touch-mvc-application/
The learning curve is quite steep but once you understand it it's a really good bit of kit to know your way around.
If you don't already understand the MVC (Model View Controller) architecture then it's going to be a bit tricky but the tutorial explains it all pretty well.
My advice would be start following the tutorial. Stick to it, get it working and THEN adapt it.
Good luck.
With Sencha Touch 2, the team have created a bunch of guides which hopefully help ease the pain when trying to learn the framework.
I suggest you first take a look at the Getting Started Guide, and then move onto the Building your first App Guide. These both should give you a kick start on where to start.
After that, I would definitely recommend you take a look at the code of their various examples, and then try modifying it. When I was first learning the framework (and JavaScript in general) I found that taking existing code and modifying it was definitely the easiest way of learning. Obviously this varies from person-to-person, but it is always a good step.
Much of their documentation have previews and examples which you can actually edit the code inline, which I have found very useful in the past. You can view an example of this here.
The Touch Forums are very active. Almost all topics get responded to within hours, and I have never seen a post which was never responded to.

Best way to learn to master the AppKit framework

I've currently been learning Objective-C and Cocoa for some time but I feel that I need to know more about the AppKit framework. I'm often in doubt about which components I should use for specific uses. For example I've used much time researching how I should simply switch between two NSViews (in the same way as NSTabView but without its tabs and for example in an IBAction).
I've read Cocoa Programming for Mac OS X by Aaron Hillegass but I'm looking for what to read/do next to widen my knowledge about the AppKit framework and about developing user interfaces with Cocoa.
What do you recommend me to take a look at?
Thank you in advance.
Four or five years ago, I was asking the same question. I had just finished Hillegass' book as well, and wasn't sure where to look for "more."
To be honest, what worked for me was learning by necessity. Think of an idea for an application you'd like to write, and just write it. The problems that you encounter along the way will help you ask more specific questions, and you'll quickly build your skill set. There's rarely a be-all, end-all answer to a programming question. Experiment, and you'll find out what works, what doesn't, and how to work your way from the latter to the former.
If you find yourself asking questions like, "Well, I guess I still don't know how to do something like A...", then either you can search for tutorials/forums on how to accomplish A, find the preferred or official alternative to A, or maybe you didn't really need to do A in the first place. (And you're just asking questions for the sake of asking questions.)
If you're really hell-bent on learning everything, you could always just read through Apple's documentation, or examine the classes/discussion at CocoaDev: http://www.cocoadev.com/index.pl?AppKit
Learn by tinkering. AppKit is pretty straight-forward, and using it like it was intended is dead simple. When you're trying to use a class, the documentation usually contains a helpful tutorial, and everything you need to know about the class.
When you come across a control that doesn't exist, or isn't easily available, don't be afraid to subclass and make your own versions. There's also lots of open-source controls and UI code out there on developer blogs. As always, Google and StackOverflow are your friends.
I agree with all of the above, (and I am still asking the same question you are), but I will add one more resource, if you haven't already discovered it. If you look up an AppKit class, such as NSProgressIndicator, for example, in the Apple Documentation, there will often be sample projects supplied by Apple, and you can use them to discover how they used the AppKit class. Unfortunately, some of these haven't been kept up to date, but they are still useful.

Objective C for beginners

I was just asked to talk about Objective C to a bunch of High School student for 20 minutes. They have no experience with programming at all. What topics should I cover? Should I define vocab such as Method, Class, Variable? Or should I do something else?
Any comments are helpful!
Since you obviously cannot possibly teach them anything practical in 20 minutes, instead why not try to give them teasers into what you can do (instead of how to do it) to encourage them to learn more.
One such idea I have seen is that you could demonstrate an application that searches for all local bluetooth devices and displays them on the screen in a creative way. (ie when they turn on their phone bluetooth their phone id will appear and start floating around the screen)
Only catch is if you have any really clever students you may end up with mobile phone names changed to swear words...
20 minutes gives you almost no time to chat about programming concepts. I would simply display a "hello world" type application and give a very high-level overview of the different tools and languages needed to develop this program.
I'd recommend doing something to show how the tools work and introduce objects as the building-blocks of the app. I did a demo in about one minute, drag a webview, textfield and a few buttons in IB and make a full web browser without writing any code :-). Explain that each of those things is an object and what that means in the context of the app for the remaining 17 (then take questions). I used that demo to launch a talk on MVC but that might be too much depth for your audience. For reference my talk is on slideshare: http://www.slideshare.net/iamleeg/adopting-mvc-in-cocoa
How about telling them about Smalltalk history, the creative outburst at PARC, and the philosophy underlying this branch of OO language? Then quickly explain that ObjC is an attempt to pair this philosophy with an efficient, universally known language (C). Present NeXTstep and OSX as a further outgrowth of this, and land on the unusual features of the iPhone API (from a developer's perspective).
This will give them some history, a glimpse of the creative and technical issues faced by programmers, and a sense of the role computer languages play in the broader development of consumer computing. You can even show them some syntax comparing Smalltalk/ObjC/C/C++/Java, for example. Without going into detail, that might give them some sense of what a programmer's reality is like.
I would say no history. It's very vague as it is, let alone that AND programming together.
Do something like:
http://teachingkids.railsbridge.org/2009/08/15/teaching-ruby-to-high-school-girls.html