From iPhone to Mac programming - iphone

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.

Related

Is it possible to port an iOS app to Windows using GNUstep? (for learning purposes)

I am an Objective-C newbie, who still does not have a Mac, but still I want to practice the language. I heard that in the non-Mac world, GNUstep offers a good alternative to Cocoa, and can be used as a lerning tool for new objective-c developers. My question is, since GNUstep ports a lot of the Cocoa classes, what are the chances of me porting an iOS game + its development framework. I am talking about Canabalt for iOS (https://github.com/ericjohnson/canabalt-ios) which is based on the iOS version of the Flixel framework. I would like to know whether there is even the slightest chance of being able to port & run this game on windows using GNUstep. Remember, that this is entirely for educational purposes, so please, do not look for any practical value in it, besides me getting better with ObjC :)
I guess that it should be technically possible. In general, what are the chances of porting any iOS app to Win using GNUstep?
I think you'd be better off porting a Mac application than an iOS application. While the iOS frameworks (UIKit mostly) are close to those of Mac OS, they are still quite different. Beyond the code differences there are HUGE paradigm shifts between iOS and Mac, in the limited screen space and the lack of a mouse.
GNUstep is close to Cocoa, so you'd be able to port a Mac app with a bit of work, but not so much an iOS app.
If you do get serious about cross-platform objective-C you may want to check out cappuccino and cocotron. They are both nods in this direction. If you don't have a mac that's still going to be a bit tougher though. A used mac mini might go a long way towards happiness here.
Good luck!
I sure think it is possible. Only question is if you think it will be worth the time spent. It's hard for me to give a time estimate here, since I don't know how good you are. Best way to find out probably is to just dive into it. Don't worry too much about success - if it seems too boring or hard, just do something else.

Closest thing to XCode, Objective-C on Windows (Not Hackintosh), perhaps interface-builder

I have to do some XCode/iPhone SDK work tomorrow, and i would like to know how I can prepare on Windows. What is the closest I can get to XCode and/or Objective-C developer experience, ideally IOS or similar Objective-C GUI.
Can also be say an interface-builder that works in a similar way.
I know Hackintosh/Vmware solutions, I think it would take a bit to long, especially since i have an AMD laptop with not to much RAM (i do have an Intel netbook)
Remark 1
I might actually have access to an old Power-PC Mac (i saw in some other threads that this might be possible). Though the question still stands.
Xcode, iPhone and IB are substantially different development platforms to anything I have seen on Windows, in both large and small ways. You have practically zero chance of gaining any insight into Xcode/iPhone programming by tomorrow without using the real thing.
The little time you have would be best spent reading up as much as you can online.
I agree with Marcelo, your time would be best spent reading. The iPhone Dev Center is a good place to start. I suggest starting with the Objective-C primer and moving on to the iOS Application Programming Guide.
For an introduction to the tools (Xcode, simulator, etc) the iOS Development Guide is a pretty good overview.
The closest you can get is GNUstep and its associated tools. It's emphatically not the same as Apple's environment, but it's derived from the same lineage. Cocoa was derived from the OpenStep frameworks, as is GNUstep (and GNUstep tries to track Apple's additions, though they lag a lot). Xcode and Interface Builder evolved from the OpenStep Project Builder and Interface Builder, which were also the basis for GNUstep's ProjectCenter and Gorm. Gorm can even open Interface Builder's nibs.
I'd agree with Marcelo without a Mac OS running somewhere your chances will be very limited.
You can probably start trying out some ObjC with GNUStep for Windows. But i actually did not try it.
http://www.gnustep.org/experience/Windows.html

Monotouch or Titanium for rapid application development on IPhone?

As a .NET developer, I always dreamed for the possibility to develop with my existing skills (C#) applications for the iPhone.
Both programs require a Mac and the iPhone SDK installed.
Appcelerator Titanium was the first app I tried, and it is based on exposing some iPhone native api to javascript so that they can be called using that language.
Monotouch starts at $399 for being able to deploy on the iPhone and not on the iPhone simulator while Titanium is free.
Monotouch (Monodevelop) has an IDE that is currently missing in Titanium (but you can use any editor like Textmate, Aptana...)
I think both program generate at the end a native precompiled app (also if I am not sure about the size of the final app on the iPhone as I think the .NET framework calls are prelilnked at compilation time in Monotouch).
I am also not sure about the full coverage of all the iPhone API and features.
Titanium has also the advantage to enable Android app development but as a C# developer I still find Monotouch experience more like the Visual Studio one.
Which one would you choose and what are your experiences on Monotouch and Titanium?
Like any which-tool-or-platform-or-language-or-framework-or-whatever question, it should really come down to what you want.
Forget all the if-you-want-to-develop-for-this-platform-then-you-have-to-pay-your-dues advice. If you're interested in learning Objective-C, Xcode, and associated Apple bits, then go for it. I did. It's been fun, but my interest was in developing iPhone apps. Learning a new language, framework, and IDE was just a bonus (I like this stuff). It was also necessary when I started.
I've been working with MonoTouch since it was released, and I love it. I prefer C# to Objective-C, and I like having access to the subset of the .Net (Mono) framework that MonoTouch provides. There are certain things that are simply easier to do with .Net than Cocoa (string manipulation, date manipulation, anything XML, etc.).
I also like not having to deal with reference-counting anymore. I was spoiled by years of not having to keep track of resources at that level. I don't mind having to clean up after myself, but I don't want to have to manually do something that every other modern dev platform I've used does for me automatically. Plus, even for seasoned Objective-C devs, reference-counting isn't a no-brainer. Scroll through OS X's console output sometime to see how many apps crash due to memory-management issues (I know - this can happen with basically any app, but it's far easier to make the mistakes that lead to this situation when you get overworked devs involved whose attention spans have been destroyed by twelve hours of if this and if that and else this and else that and blah blah blah).
I still use Objective-C/Xcode - I've really learned to like Apple's tools. I honestly feel they're awkward and a bit arcane, but still fun.
But... then I also like this:
public string SomeString { get; set; }
To do the same thing with Objective-C (on the iPhone, anyway) requires that you declare a local variable to back the property, write the property declaration, and then use the "synthesize" directive to have the property generated for you (depending on what property attributes you specify, you might have a property that wraps getters and setters that take care of reference-counting for you - overall, this is a time-saver, but the C# Way is the clear winner here).
That's just one example of how MonoTouch can make your life easier, especially if you're used to .Net/Java/Python/other languages that don't require that you get your fingers dirty with memory-mangement (unless you want to).
As far as iPhone-ness is concerned, aside from brining part of .Net to the iPhone world, the MonoTouch namespace maps to CocoaTouch, so if you're confused about, say, the MonoTouch UIViewController, you can just hop over to Apple's docs on the UIViewController. MonoTouch .Net-izes CocoaTouch, but it's close enough that you're unlikely to hit a wall (that wouldn't have also hit if you were using Xcode/Objective-C). It's slick.
Titanium is different. Since they're trying (trying) to create an abstraction layer that lets you write the same app for multiple platforms, you're going to deal with the usual drawbacks: Totally different APIs, loss of flexibility (the same could be said of MonoTouch, but not remotely to the same degree), and basically having to learn a whole new platform (which is what you're trying to avoid by getting around Xcode/Objective-C/CocoaTouch, right?).
I also hate JavaScript, so I'm going to be biased against Titanium. But even if that weren't the case - even if I could use a language I do like - the APIs don't tickle my fancy. Or my anything.
Regardless of the dev tools you choose, you will end up having to learn something about CocoaTouch. Whether it's Xcode/Objective-C, MonoTouch, or Titanium, something is going to break or go all wonky on you, and you're eventually going to have to refer to CocoaTouch documentation.
If I were giving a talk on iPhone development (which I have, and which I will be doing again), and if I were to discuss alternatives to Apple's dev tools (which I will), I would still strongly encourage devs to at least work through a few basic iPhone apps using the native tools. It's going to make you a better developer for the platform - period. And you can use this beginning phase to determine if you even want to use anything other than the free Apple-supplied bits. You might not. I've been using MonoTouch because it pleases me - not because it's necessary.
So, to summarize a few basic criteria:
Preference (language/frameworks)
Devices (do you care about non-iPhone platforms or think you might someday?)
Comfort (if you like and know C# MUCH better than Objective-C, there's no reason not to go with MonoTouch)
And don't listen to the naysayers unless they've actually used the tech they're talking about. For example, I've read about Titanium, but I'm not experienced with it - I just know that I don't want anything to do with it on account of my preferences. That doesn't make it "bad" - just something I don't want in my life.
The Objective-C crowd can be impressively zealous. While there are plenty of open-minded devs in it, there are so, so, so many who think Objective-C and Cocoa and blah blah blah are THE last dev tools devkind will ever need.
Ignore them.
If you're worried about support, here's some stuff to consider:
Apple is likely to remain current, as they're the ones making this junk.
MonoTouch is likely to remain current - the Mono peeps have done an amazing job keep up with Microsoft, and I see no reason why they won't do the same with Apple. I'm blown away by what they do. And despite MonoTouch having been released, like, five minutes ago, they already have an update out for iPhone 3.1 stuff. They're serious about this, and I think they're magic. They're the Keebler Elves of the dev world. They sit in their secret layers and crank out stuff everybody (ok - not everybody) likes, but that nobody else would even attempt to do.
Titanium is either going to become an awkward unified API for writing apps for multiple platforms that is entirely its own thing, or it's going to become more and more splintered as the capabilities of different platforms diverge. Yeah, that's a bunch of typical armchair nerdly future-gazing... I should have prefaced this bullet item with "It's my opinion that..." If only there were a way to go back and change it.
Go with what you like. MonoTouch is a "safe" alternative to Apple's stuff. I'm afraid Titanium is going to go down the same old oops-this-super-high-level-platform-abstraction-layer-stuff-doesn't-really-work road that so many other technologies have. But if you're doing something simple, there's no harm in giving it a shot, especially considering that it's free during the beta period.
These are fun and interesting ways you can build iPhone apps. But, for truly rapid native iPhone development, your best bet is the free iPhone SDK and Xcode.
To be honest, the hardest things to learn are the capabilities of the frameworks themselves, NOT the language syntax. But that is an issue you have to tackle either way as these IDEs/Languages still require you to grasp some of the conventions of Cocoa (and Cocoa Touch).
I don't say this as a Cocoa / Objective-C snob, but if you know C (which as a C# dev you do) there really isn't any barrier to entry.
In addition, you will have access to tons of tutorials and sample code that just won't be available for these fledgling translators/IDEs/languages.
Learning another programming language is rarely a bad thing, and as an experienced programmer, your time investment won't be as large as you think.
I've created an open source project http://propertycross.com that helps developers select a cross-platform mobile framework by showing the same application implemented with Sencha, Titanium, Xamarin and more. This project allows you to easily compare a wide range of frameworks in terms of end-user experience, code, IDE, developer experience etc ...
I kinda like the idea of providing means to quickly get a grip on iPhone dev with techno people already know.
I personnaly, as a Java developer, use iSPectrum (http://www.flexycore.com). It also come with an IDE, debugger and stuff, which make it really convenient to develop with because it benefits of all the power of Eclipse Java plugin.
Being based on Java, this also allows to easily reuse already existing code from other java apps, which can be really handy providing that Java is present on almost all platforms (desktop & mobile alike) except iPhone.
Plus it's free for open source projects.
I'd rather consider these kind of solutions, because I don't like the idea of coming back to developing in emacs :) .
I know this is an old topic, but in the interest of staying current, it looks like MonoTouch and other cross-platform frameworks are going to be banned in SDK 4.0. Your only "safe" bet for writing iPhone apps is to use XCode and Objective-C, at least for the time being.
If you're C# programmer why you shouldn't invest some times to learn Objective C. Honestly speaking, it will not take much time from you. But you feels good to work in a new platform with new language. Learning new things all time fascinates me.
There are numerous ways to get on the device. Apple has stated in the SDK license that the only approved way to get on the device is via C, C++, ObjectiveC, and Javascript.
It appears at this point in time that apps built on MonoTouch and Appcelerator Titanium are being accepted into the App Store. Thanks to the license change, there is much fear, uncertainty and doubt on this subject. Apple has scared everyone not doing ObjectiveC.
I would suggest that you do whatever makes the most sense for you as a developer. If you know C# and .NET, you should go with MonoTouch. If you know ObjectiveC or the Mac platform, ObjectiveC is probably the way to go. If you know X and it's on the iPhone, well, X is where I would suggest looking first.

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)

Is it better to start how to code in Objective-C for the desktop before you venture to the 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