Is it better to start how to code in Objective-C for the desktop before you venture to the iPhone? - iphone

I have C/C++ experience so learning Objective-C is not completely foreign to me. However, I noticed that writing an application for the iPhone is not as simple as for the desktop platform. Should I start to get some solid experience on the desktop before I jump into the iPhone? I am not a commercial developer, and merely doing this as a hobby and for learning purposes. What is your recommendation?

For what it's worth, a comment from another newcomer to iPhone development...
My background - I was a C Programmer about 15 years ago and since then I've moved around technologies quite a bit - I'm now an Adobe Flex developer in my day job. By night, however, I'm trying to transform myself into an iPhone developer ;-)
So I bought a book on iPhone SDK development - 'iPhone in Action'. I also bought 'Programming in Objective-C 2.0'. I thought I'd be set with these two but after a couple of days reading and working through exercises it was clear that... I was hopelessly lost!
So I bought another book - this time, 'iPhone SDK Development' from the Pragmatic Bookstore - this is a work in progress book but looked 'right' for me. Turns out this book took me further - it's a great piece of work - however, the early chapters were paced nicely and I was able to follow along and then all of a sudden they began to assume I could recall perfectly the lessons learnt and the procedures followed in earlier chapters and I began yet again to flounder a little - the worst thing I find when trying to learn something from a book is to have to jump around from place to place constantly to make any sense of what I'm meant to be doing.
So (yeah, I know... but bear with me...) I bought ANOTHER book... 'Beginning iPhone Development' from APress. Now THIS book assumes nothing. For a beginner to iPhone development, THIS book hits the target. No jumping around necessary and finally I found I was progressing.
However, what I'm finding is that ALL three books in CONJUNCTION with one another really seem to provide me with a more complete picture - collectively I have a great set of tutorial and reference material. The Objective-C book I've not touched on so much yet but I expect that to be what I need it to be - a reference manual for the language; I'll not need that until I'm much deeper in to the guts. I'm slowly emerging from that horrible "in at the deep end and I can't swim very well" feeling to one where I can at least tread water. Hopefully with a bit more paddling I'll be able to touch the bottom - certainly my confidence is returning ;-)
So anyway, to address the original question - personally if I did this all over again, I don't think I would have gained anything by starting out building for the Mac first and then to the iPhone. I would definitely have lost less hair had I bought the APress book first - that for me was the book that made complete sense of everything for me. I think then the 'iPhone SDK Development' Pragmatic book was the best backup/followup book. This is the path I've suggested to a colleague and I'm confident it's a good one.
Hope this helps!
Jamie.

It is definitely helpful to have some Cocoa experience before going into iPhone development, but I personally wouldn't sweat it that much. Learning how to use the Cocoa framework and getting comfortable with it in general would be beneficial, but there are certain aspects of desktop Cocoa programming that you will find have little relevance to iPhone programming (e.g. user interface design with Interface Builder). Also, there are unique aspects of iPhone programming that normal Cocoa programming won't really prepare you for. (Some experienced Cocoa devs still had somewhat of a learning curve when they first got into iPhone development.)
In other words, I would recommend learning the fundamentals of normal Cocoa development, but you won't need to become a Cocoa guru in order to learn how to develop iPhone apps.

If your only intend in coding desktop apps is to get familiar with Objective-C, cocoa and Xcode, it is not worth.
You will learn nothing starting with desktop apps that you would not learn getting straight in iPhone apps. Desktop apps are not simpler than iPhone apps, they are just different.
It may even be counter productive if you learn specificities of desktop apps that you will have to 'unlearn' on iPhone development.
Of course, if your intend is to get into the OS X ecosystem, learning both would be very valuable.

In some ways the iPhone is simpler for a C/C++ developer. No garbage collection is the big one. If you start on the desktop and get used to GC, you'll have a hell of a time when you hit the iPhone.

There is no need to or benefit in learning desktop Cocoa before moving to UiKit on the iPhone. There may be some disadvantages.
Although there are a lot of concepts shared between UIkit and Cocoa they are no easier to learn on the desktop. And at the end of the day, they are not identical. Similarly there are a lot of frameworks that are shared between iPhone and the desktop - in these cases, there is nothing to be gained from using the desktop versions before their equivalents on the phone.
There some difficulties that you will face only on the iPhone and things that might make things easier on the desktop:
you develop on the target machine, on iPhone, target management is more difficult
iPhone is memory and processor contstrained
there is no Garbage collection on iPhone
My view is that it is a good idea to get used to these issues as soon as possible rather than getting into "bad habits" on the desktop (or just generating misunderstanding when you go to iPhone).

If you have any development experience you know that all languages are alike, and you only know if you fully grok it only by working with it.
My approach to learning a new development environment is to pick a problem you want to solve (and since the phone is in your pocket all the time, you're likely to have some idea), and bang your head on it.
There's a ton of apple sample code, answers here and on other sites. Start with a working sample app that is not too far from what you want to do, and tweak it over time. You are gratified by a working app, find out about problems right away, and can learn small bits at a time.

The biggest challenge is not learning Cocoa and/or Cocoa Touch but Objective-C. Once you have the fundamentals Cocoa is simple and similar to many other OO frameworks.
I suggest:
The Wikipedia article on Objective-C: https://en.wikipedia.org/wiki/Objective-C
"External links" at Wikipedia for some fundamentals of the language
Hot Cocoa podcast: http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=294050835
Cocoa Cast podcast: http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=298413458
Then the Stanford iPhone Application Programming course on iTunes U: https://podcasts.apple.com/us/podcast/iphone-application-programming-spring-2009/id384233222
Join the developer program at Apple: https://developer.apple.com

Related

why use xcode if monotouch is available?

if mono touch is available than why we should use mac environment(sdk,xcode+Interface Builder)?
what are the disadvantage of monotouch compare to xcode?
I always prefer working in the language that is most philosophically aligned with the platform I am developing for.
That is to say, the frameworks the whole platform is built around were written for and in Objective-C. As such, if you are working in Objective-C yourself for a while you understand why things are built the way they are, and can also anticipate calls that might exist or behaviors.
Just as I would not develop for Windows Phone 7 in anything but Silverlight, I would not program the iPhone in anything but Objective-C in order to get the most out of the platform. New language? That's a benefit as people should learn new languages now and then anyway. And it's not like it saves you that much time to use a language you already know since a large majority of your time will be spent learning the frameworks (which MonoTouch lets you call into).
I feel like this needs an answer from the MT camp, too.
Why eat fish, if you can have meat? Why speak German, if English is understood? Why watch CNN if there is FOX? Why vote vote for the Republicans if there are the Democrats? Why...? And so on.
It is your choice! If you have worked with C# for a long time and want to have quick results on iOS, go MonoTouch. Especially if you have a collection of APIs or methods you can reuse, MT is the way to go. If you want to learn a new language (ObjC), go for it. Even if you use MT in the end, knowing ObjC is somehow crucial because it helps you understand why things work as they do.
Hello here is my personal opinion,
I've also been on .Net world for a while, when iPhone launched the ability to create native apps, it called my whole attention and i really tried to learn objc, i took 2 books and started trying and trying and trying like for a month and then I left iPHone programming due to you had to make tons of things than on .NET was a line away for example the GC.
When Miguel de Icaza launched MonoTouch i gave it a try and i realized that most of my previously done code was fully funcional (i've always tried to separate ui code from business code) and this is really the point of .NET on the iPhone, to bring most of your already done business logic to the device.
Also on objc you wont find anything like LINQ or var keyword, consuming web services on MonoTouch its just a few clicks away etc.
If you want to target the Android platform there is also MonoDroid (monodroid.net) wich its coming out later this year the stable release, you can give it a try right now on the beta state. Also if you want to target Mac OSX there is MonoMac. So you can share class libs between all this 3 platforms (also al mono/.net supported ones) without hassle not to mention it will work on windows too and viceversa (when possible) (Also dont forget about WP7).
The only thing you will need to worry about its the UI but most of your business logic should work. here is a complete list of .NET Assemblies supported in MonoTouch http://monotouch.net/Documentation/Assemblies and also MonoTouch exposes a C#/CIL binding to all the CocoaTouch APIs.
Also the support of the MonoTouch team is awesome you can just get on IRC ans ask a question and it will be answered right away, mailing list too :)
I really enjoy MonoTouch, i know that no language is perfect for all tasks, and Objective-C is no exception.
Every example, tutorial, and piece of documentation will be written in Objective-C, and mono will just be calling into Objective-C code under the hood. If you really feel like C# is worth mentally translating everything, and adding an extra layer in your code, go for it I guess.
As a C# developer, I've found Objective-C to be horribly painful to become confident with. It's taken about two months, and two excellent resources to get to this stage.
Get your Visa card out, you'll need to spend a total of $54.
1. The free Stanford "Developing apps for iOS" lectures.
Pure brilliance, and it makes learning Objective-C very clear.
http://itunes.apple.com/us/itunes-u/developing-apps-for-ios-sd/id395631522
2. The iOS Apprentice series.
This is where you'll need to cough up the $54. It teaches you, step by step, how to program in Objective-C, and the apps you build are actually pretty impressive. Part 1 (of the 4 parts) is completely free, so you can give it a go before parting with any cash.
http://www.raywenderlich.com/store/ios-apprentice
I've yet to find any iOS books which match the clarity and friendliness of these two resources.
Finally, don't buy any books unless they specifically say that they're for iOS5 and XCode 4. This latest version of XCode is simply too different to make them useful.
Disclaimer: I don't work for any of the resources mentioned in this thread !

How good is Mono Touch in comparison to the IPhone SDK?

I'm new to IPhone development and have to decide on a suitable tool to develop my application in. Since I am know C# / .NET, but not objective C, Mono Touch seems appealing to me. But is it is worth spending the extra $400?
If have tried both, I'd be interested in your opinion.
I just posted about this at www.zouak.com, but in short for me it was a case of divide and conquer. I have years of .NET experience and honestly found learning Objective-C frustrating. Having a new language plus a new set of tools reduced my productivity significantly, also having to deal with manual memory management after years of not (prior to 2001 when I started with .NET I was a Java guy since its inception, so it's been a while) was an extra layer of "been there, don't want to go back."
I've found the MonoTouch toolkit to be very worthwhile, and while I understand some of the objections and concerns, I'm someone for whom leveraging what I know (C#) allowed me to focus on what I didn't know (Interface Builder, the API, etc.). At this point now that I've built up a significant amount of familiarity with the Apple tools I'm nearing a point where if I wanted I could look at taking on Objective-C as a new language, given that I am a lot more comfortable, but for me learning a new language isn't as rewarding an accomplishment for me at this point in my career compared with learning a platform and getting quality applications out the door is. For other folks I know they enjoy delivering "as Apple intended", and I fully respect that. Also, if Apple had a Java toolkit, I would be all over that. But the conceptual distance between C# and Objective-C is more than I'm willing to invest at this point.
That's my 2 cents,
Driss.
Great podcast on this week's dotnetrocks about this.
One HUGE factor that would sway me is the fact that they are currently working on Monodroid and I guess that WinMo 7 will probably be supported through some moonlight magic.
Imagine targetting the top 3 mobile platforms with one language? Sweet....
I've been using MonoTouch for 5 months, and really like it.
Take a look at my answer to a similar question here: MonoTouch - has anyone used this?
I am an iPhone developer, I have tried mono touch, but for me I would say NO, it's not worth the extra 400.
First of all several free frameworks exist that allow you to target multiple platforms at once using different (usually high level) languages, such as PhoneGap, there's even a Flex framework somewhere, without counting Unity3D which actually uses C# and even allows you to deploy on iPhone and Nintendo Wii.
Some of the Cons of using this third party frameworks are:
1- Extra software layer, which obviously increases the possibility of failure. Last year it happened with Unity3D. Somehow the applications developed with it started being rejected by Apple (official Unity announcement here) , Unity guys responded fast, and I think they fixed the issue with Apple in 3 days. But what if 3 days is too much for you, or even worse, what if the external framework that you are using to develop doesn't have that quality of support and the 3 days end up being weeks?... what if your applications got broken with an OS update ?
2- You totally loose Xcode debugging chances (loose the symbols), and you are kinda reduced to printf debug. Of course you can debug in the Mono IDE, but still, Xcode is a powerful beast and all the SDK Betas are delivered to the developers to be used with particular Xcode versions.
3- Binary size tends to be bigger in comparison to native Objective-C applications. ( 6 to 7Mb larger in average ), and remember that if your application is above 20 Mb it can't be downloaded from an iPhone using 3G or Edge, ( which is the most popular way to install apps ). So if that matters to you, it's another issue.
In conclusion:
If you want to use MonoTouch because you don't know Objective-C, go for it, but still I would really recommend you to take a bit of time to learn the Objective-C language and the official Apple API's. Here's a great point of view about this.
I would say no, because the biggest thing to learn about the iPhone SDK is not Objective-C, but the APIs instead. Even if you used Mono Touch, you would have to learn the API for the iPhone.
It never hurts to learn a new programming language.
(However, don't listen to me, because I am using Lua to write my iPhone applications...)

MonoTouch - has anyone used this?

I'm a .NET developer trying to make the leap into objective-c iPhone programming. I created my first app - just a simple portfolio with multiple xibs.
I've just come across MonoTouch which lets you develop iPhone apps in C# or .NET. Has anyone tried this out? I'd be interested to know people opinions on it.
I have been using it for 5 months now, and I have an app developed using it in the App Store ( http://escoz.com/quicklytics ), as well as a few internal projects deployed at a client.
Here's my point of view:
If you're a .NET developer, and want to develop for the iPhone, you'll need to learn two new things: Obj-C and the iPhone SDK. Both things are quite different from .NET, and it can be quite difficult to get going, specially if you have a deadline. In general, you'll end up getting stuff done, but mostly by copying-pasting a lot of random code from the web for months and months. Yeah, you may actually spend the time and learn it properly and not do that, but that will take a lot of time.
Using MonoTouch allows you to totally skip the first problem (obj-c) and helps tremendously with the second (sdk). After a couple of days reading and watching videos online you can already be fairly productive, using things you're familiar.
Yeah, it does cost at least $400.00, and if you're thinking about developing stuff for fun over the weekend, that may be a little expensive, but if you're thinking about writing code for work, this is a no brainer.. The amount of time that it'll save costs a lot more than the $400.00.
Size of apps: the apps will be larger (6-7Mb larger in average): nobody cares about it, honestly.
Speed: while technically it is possible to make obj-c apps that run a little faster than C#, in practice that simply doesn't happen: monotouch is as fast as obj-c for all purposes.
Bugs: not having to deal with memory leaks all the time and having a higher language to develop in is a huge deal.
Even if in the end you want to pick up Obj-C, I would highly recommend you start with MonoTouch and get familiar with the APIs. The demo is available for free and allows you to do everything other than deploying to an iPhone. Only when you know how the API works move to Obj-C (if you still want to do it at the end).
One last point: if you're thinking about porting your apps to other mobile platforms, MonoTouch seems to be the platform to use right now: most of your code can be ported to the Windows Phone SDK, and Apple will release MonoDroid (MonoTouch for Android) in the next 5-6 months.. This really matters to me, maybe it also matters to you.
Tried it, loved it.
Being able to re-use .NET knowledge is a definite plus (even though learning Obj-C is most definitely still encouraged.
The only downside is that the executables are larger than their respective Obj-C counterparts. That...and the cost associated with the license (if you're going to distribute your apps).
I tried it.
If you think you're going to program many programs for iPhone, I think is better to learn Objective-C. But, if you have some big source code or existing programs written in C#, that MonoTouch may be the best solution for you!
Rory Blyth addresses this very point in a very similar question:
Monotouch or Titanium for rapid application development on IPhone?
Our whole dev shop moved from XCode and Objective-C to MonoTouch. Most of the team also have .NET C# skills.
We're about 2/3 more productive in our XMl/database-centric apps + web services . Monotouch has a lot of built in tools for those things.
It's quite expensive, and you still need a Mac.. so if your idea was to stay in Windows and write iPhone apps using Visual Studio, you're out of luck sorry... At $399 as the lowest price, on top of the $99 for a developer license from Apple, I don't think it's worth it unless someone else is paying (eg, a corporation etc). You'd be better off sticking with Objective-C and Xcode, since you've already played with it.

From iPhone to Mac programming

I've looked through the site to make sure this isn't a duplicate. Apologies if I've missed something.
I've been doing iPhone development for about a year now, and I'm comfortable with Objective-C, Xcode and Cocoa (at least what's used on the iPhone), but programming for OS X seems much more involved.
What are some good free resources for someone like me? Most of the stuff I've seen is about learning Objective-C and Cocoa, and I really want to get into the parts of IB I'm not familiar with and anything else that's important on OS X that isn't on the iPhone.
While the iPhone development evironment isn't strictly a subset of the Mac, since there are some improved and iPhone-specific bits, it is nearly so (and it's mainly the good bits). Thus, the Mac is probably the easiest platform to move to from iPhone.
On the Mac, you will especially want to learn about Cocoa Bindings, which underly a lot of modern UI work, but aren't (yet) on the phone.
Addressing your specific question, some well-respected free Mac coding resources include:
the canonical cocoa-dev mailing list run by Apple (which, unfortunately, has only the woefully lame web access implemented by Apple, and sporadically augmented by unreliable third-party efforts, making it mostly useful via actually subscribing to it from one of your email acccounts)
the CocoaDev wiki
Rogue Amoeba's Mike Ash has an unusually useful Q&A Fridays series on his blog
the advanced Mac programming book from Aaron Hillegass, Advanced Mac OS X Programming
although Apple's docs are pretty good now, in the bad old "description forthcoming" days, a lot of us learned how Mac OS X ticked from open-source code published by reputable software houses, like Omni's frameworks which you are free to embed as-is into your apps, or cherrypick code from
(Hmm, I don't usually post here, so I was prohibited from hyperlinking the above references... can I put them in as text? Uh, nope! Well, there's always google, I guess.)
Thankfully, Cocoa on the desktop and Cocoa Touch are very similar. I would recommend just downloading some beginner sample code from Apple's website. Since you already know Objective-C/Cocoa, you should be able to follow along pretty easily. If some parts are confusing, you can skim through Apple's guides.
Things that are the same:
Design Patterns (target/action, delegate, data source, first responder, etc.)
Objective-C
Interface Builder
Things that are different:
A control can have only one target and action. On the iPhone, you can have one target/action for a touch up inside, touch up outside, etc. On the Mac, there's only one.
NSWindowController for loading xibs (conceptually similar to UIViewController, though)
Edit: Overall, the main different the iPhone has more 'pre-built' UI classes (UINavigationController, UITabBarController, etc.) you can use in your app to make it look nice and pretty (and most importantly, consistent with Apple apps).
I started out with Mac OS development and went to iPhone development. You probably already know the core concepts about how the APIs work. The biggest problem I see developers who transition from iPhone to Mac is getting used all the subtle ways that Mac users expect their apps to work. Things like handling the Page Up and Page Down keys to scroll your view (shame on Tweetie for not supporting this). Or handling multiple windows. Or multiple display sizes (and making sure not to position windows off screen).
For the technical programming questions, Apple's own documentation is the best place to start. For the nuances of designing for the Mac OS and doing things right, there isn't a book or web site that has all the answers, as far as I know. Mostly that comes from using apps that are Apple Design Award winners and imitating what they do.

Does it make sense to first learn Cocoa for Leopard and then Cocoa Touch for iPhone?

Actually I don't care too much about Mac OS X development. I want to do only iPod Touch and iPhone development. But anyways, I started learning Cocoa and Objective-C. But it seems like there are many differences between Cocoa and Cocoa Touch, so I am wondering if I am actually wasting my time. Should I just jump directly into iPhone topics?
There is lots of overlap, but if your purpose in learning is to do iPhone programming, then by all means learn iPhone programming directly.
As a side-effect, you will be able to pick up Mac application programming more easily if you should ever have such a desire.
I think you could go either Cocoa-Cocoa Touch or Cocoa Touch-Cocoa and still have a good grasp on what it takes to program for either platform. I tried Cocoa development on my Mac a few years ago and was pretty confused. I finally decided to take up iPhone programming, and picked up Beginning iPhone Development: Exploring the iPhone SDK, worked through that book over a few weeks, and I understand things much, much better now. Really, all it takes is a good explanation of Mac programming. I'm fairly confident I could pick up regular Cocoa programming with far less effort now. Had I started with regular Cocoa programming, I'm fairly confident I would have been able to pick up iPhone programming fairly easily. There are differences, but there are a lot of (very cool) similarities between the two platforms.
PS, I highly, highly recommend that book if you're really interested in iPhone development. It was worth every penny.
Normally I would agree with the other answers here: directly learn the topic you're interested in. But in the case of Cocoa/Cocoa Touch, you'd be better off reading Cocoa Programming for Mac OS X, 3rd ed. by Aaron Hillegass. It's just that damn good!
There are similarities but if the goal is iPhone development, you'll be much better off starting to learn on that platform and then stepping up to the Mac. There's a lot more going on both in the UI frameworks, and in terms of what IB can do so you may well get used to some aspect of the system that is not present on the iPhone (or done differently).
The NS foundation classes are much the same but even there are differences.
Also beware that the simulator will compile and run Mac code that will not compile or run on the phone itself, when using the docs always keep them focused on the iPhone SDK section.
One difference between Cocoa Touch and Cocoa is in the area of memory management.
If you happen to be learning Objective-C for the very first time (or possibly any C-based language for the very first time) I would start with Cocoa Touch.
My reasoning is that the iPhone does not support automatic garbage collection, and you may find it easier to learn the (more difficult? certainly less automatic) way first, then as you migrate to OS X development appreciate the shortcuts that the OS X platform gives you.
If you learn Cocoa development on Leopard initially, you may be frustrated at the seemingly more primitive memory management available in the iPhone.
The two are very similar, though.
Bottom line is if you want to learn to program for the iPhone, go ahead and jump to the iPhone. Mac OS X development is not a prerequisite, just a very similar skillset.
I've taught Mac developers and iPhone developers, and my experience is that it's generally best to learn Mac first, particularly because you can get a solid grounding in Cocoa using Cocoa Programming for Mac OS X, which is still the best book on learning the Cocoa patterns around. So far I haven't found a good iPhone book that teaches the key issues you need to know, and that differentiate Cocoa/Touch programming from Java, .NET and other systems. I've written a couple of articles recently that may be helpful as you think about this:
iPhone Course Syllabus
Review of iPhone Developer’s Cookbook
I've went through about the same question as you, though my initial focus was more on Mac development, the iPhone came later. I'm by no means an expert cocoa coder yet, but things are improving rapidly. I find that the things I learned about cocoa on the Mac come in quite handy on the iPhone; picking up iPhone development certainly went a lot quicker than my first steps in cocoa on the Mac...
In practice, I find both skills come in handy. I'm making an iPhone game, but the data set it uses (the actual puzzles) are created using a small cocoa app I've developed for the Mac. Is there a specific reason why you don't want to learn Mac development? You don't need additional development/designing tools for your game?
(screenshot of the mac app: http://www.qixis.com/images/edit16-screenshot.png)