Examples of Cocoa/Objective-C and Distributed Objects? - objective-c

I am learning Cocoa and Objective-C (well, and C) to make a few Mac apps I've had floating around. I need to use Distributed Objects, but am having trouble finding simple, concise examples. Does anybody know of any?

A google search came up with plenty of hits. The Apple docs are also good. Late Night Cocoa also has an episode on it.

I maintain the comp.lang.objective-c FAQ, and there's an example in there: How can I forward messages between remote objects? It's very short but should give you the basic idea, on which you can then hang the Apple and GNUstep docs to which it links.

It's a fairly old article but this is probably a good starting point for distributed objects. I personally found it easier to start with the older tutorials and work my way up to the more recent ones which use new technologies such as Core Data.
http://cocoadevcentral.com/articles/000062.php

I discovered this project at SourceForge which is a fairly large Cocoa project. It uses bonjour and distributed objects, and other then that I've found it to be a good resource and example. Just thought I'd put that out there in case anybody comes across this question.

Related

Objective C ORM

I am new to Objective C. In previous practice I accustomed to use ORM-like frameworks to access the database.
Could anyone please recommend any decent ORM framework for Objective C?
The following are for SQLite on iOS:
FMDB
chibi-ORM
sqlitepersistentobjects
UPDATE: DBAccess has now been replaced by the open source ORM Shark.
We have recently released a free to distribute and use ORM for Objective-c / iOS called DBAccess, which can be downloaded from http://db-access.org/, it has taken several years to develop and has now been deployed within many applications.
The documentation is fairly basic, but is slowly getting created/updated and we welcome community feedback and suggestions.
There is also a roadmap available to detail what features are going to be released in the up-coming releases.
It may not be for everyone, but I hope our effort will help some in the community.
NOTE, I have been alerted to the fact that it is bad form to promote your own products in a forum such as this, but I just wanted to add that I am only posting this in answer to the OP because I feel it does bring something useful to the table and I sincerely hope it will prove helpful to some people, even if it's not for everyone.
UPDATE: DBAccess has now been replaced by the open source ORM Shark. It is API compatible, and is available on github. http://sharkorm.com and https://github.com/sharksync/sharkorm
Thanks Adrian_H
There are a lot of alternatives out there, but in my opinion, nothing is better than Apple's Core Data. It is easy to use and implement, and is incredibly well documented (as everything that comes from Apple).
One excellent resource to learn Core Data quickly and use it right away is Paul Hegarty's CS193P videos available on iTunes U, which you can download using the following link:
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=480479762
SQPersist is a Objective-C Persistence framework wrapper around SQLite based on FMDB :
Visit Github page
I totally recommend Realm. IMHO it is an excellent choice for its simplicity and performance.

Development frameworks for 2D game?

I wanted to start working on a simple game concept I have, just as a side project/hobby/learning experience.
Pygames or Pyglet came immediately to mind, but it looks like they aren't being actively developed. Or perhaps they are, but extreeemely slowly.
I want a high-level programming language, multi-OS support, 2D focus (or suitable for 2D stuff, anyway), and active development. What are my options?
I use Pygame and think it is a great option. The community is fairly active, I see a new or updated project posted about every other day on Pygame's homepage.
Another good option would be the Love2d framework, which you can find here: http://love2d.org/. Love2d uses the language Lua, which is a high level, beginner-friendly language like Python.
Pygame and Pyglet are indeed excellent choices. If the level of activity concerns you, just take a look at the Google Code page for Pyglet, seems it's fairly active to me.
If you prefer more actively developed engine (less documentation, but more up-to-date approaches), check out the Monacle Engine:
http://monoclepowered.org/
If want to get your hands dirty and take a more Do-It-Yourself approach, projects like
SDL, SFML and Allegro may provide a good foundation for a cross-platform 2D engine.
Another, more recent project that provides a very useful set of 2D primitives is the Clutter framework:
http://www.clutter-project.org/
Add a sound library like FMOD or BASS and physics engine like Box2D or Chipmunk and you may build pretty much everything.
The PopCap (a.k.a. SexyApp) engine was a popular choice in the past.
http://sourceforge.net/projects/popcapframework/
For real-world example, check out the acclaimed indie game World of Goo, which is using it.
http://en.wikipedia.org/wiki/World_of_Goo
If python API is preferred, there seems to be an effort to provide one here:
http://www.farbs.org/pycap.html

Learning Cocoa. Should I delve into Apple's documentation?

I have built some basic apps for iPhone and Mac with a general understanding of Cocoa, but haven't had a detailed understanding. Now I want to go deeper.
I have just finished the Objective-C documentation at MacDevCenter. It was great to get in-depth look but took far too much time, specially because a lot of it is conceptual, and it's hard to build detailed examples to make use of the concepts.
Now I am on to Cocoa, but feel like it would be too much work to go through 250 page documents for Cocoa itself, then KVC, Cocoa Bindings, and Core Data.
Would I be better off at this stage picking up a good book on Cocoa (Hillegass' is too sparse I think) or should I just bite the bullet and go through the docs?
Apple's documentation is generally excellent. The API reference in the very least is some of the best I've read (right up there with Java's API reference), and is a very valuable asset.
I'd suggest reading the overview pages for topics you're interested in to get a general "feel" for how they work and a starting point, and then just start writing code. You can refer to the documentation to fill in blanks that you encounter while writing code.
Writing a small project to exercise your use of APIs you'd like to learn is a great way to get started.
I've found Hillegass's book to be far from sparse. In fact, I've found it to be one of the most dense books on programming I've read. I've re-read most of the chapters at least 4 times, and each time understood more. By re-reading, I've understood the reason he included a certain paragraph and how it fits with the bigger picture. He spells everything out very clearly and doesn't waste words. I'm amazed at the amount that's contained in that book.
You mentioned that you want to learn by doing, instead of by reading. The Hillegass book has a section at the end of each chapter where you put what you've learned to the test, by building an application.
Of the three things you talked about, KVC, Cocoa Bindings and Core Data, the first two are covered very well. I did find the Core Data chapters to be a lot more sparse. That's the only part of the book that I haven't been able to understand without other documentation. The Pragmatic Programmers book covers it much better.
Anyway, the answer to your question is: it depends. If you've managed to work your way through the Mac Dev Center documentation, it may be that you're the kind of person who learns easily from that style of resource. If you like learning from books, the best one is Hillegass.
I'd recommend an excellent book released some time ago: ‘Cocoa Design Patterns’ by Erik M. Buck and Donald A. Yacktman.
Of course you can dive into Apple's documentation, but to me, I found Hillegass' book is a good start for learning Cocoa. The value of the book, I think, is the introduction of the conventions and idioms of Cocoa.
Is it really clear for a new Cocoa developer to find out information on issues like when and when not to send message autorelease to an object? You can argue that a single Googling will do, but how do you know there are these kind of issues in the first place?
Go get a good book, look through it and take notes. It could save your time. For me, on Cocoa, the book is Hillegass'.
Hillegass' book will drive you to the free documentation every time he fails to make sense in order to be "funny" (i.e. every other paragraph) anyway, so unless you just want to give him $40, you will be much better off sticking to what Apple gives you au gratis. At the very least you won't pick up any of his horrible UI design habits.
You don't really need to go through ALL the bindings and Core Data docs page by page--half of it is stuff you'll likely never use. Knowing where to look for more information is far more valuable a skill than memorizing APIs.
The reference is great and invaluable, but might not be the easiest way to start coding (as people have mentioned).
I started looking at the stanford lectures on iphone development, then coded as I went along. I've actually used them as reference once or twice as well... They are available on itunes for free.
It depends on what other programming experience you have and how you learn best. If you're fairly new to programming in general, I'd recommend Hillegass to start. If you're fairly competent at OOP but don't know Objective-C, you can go for Apple's "Introduction to The Objective-C Programming Language" to learn ObjC's language features. If you've programmed using paradigms other than OOP, you could look for general OOP book recommendations here on SO (e.g. "Best Referece to learn OOP independent of languages?"). I also second Jonatan's recommendation to check out what programming videos iTunes University offers. They are recordings of lectures from top-tier universities and generally of good scholastic quality (I only qualify this with "generally" because I haven't seen them all; the ones I have seen invariably were of quality). No matter where you go to learn ObjC and Cocoa, you'll still yourself using Apple's docs as reference.
As you learn, you might also find CocoaDev a useful ancillary source.
Aaron Hillegass's book is the text for his one-week cocoa development seminar, and it has been revised over several years of teaching Cocoa to beginners. Aaron's course is where Apple sends their own employees, now that they don't do the Cocoa course in-house anymore.
Apple's documentation is an excellent reference, but I agree that it's a huge resource to try to learn Cocoa from in the first place. Besides, you probably don't need to know the whole API up front -- just learn each part as you need it.
When I started learning, I just picked a project, sat down and started trying to code. When I ran into something I didn't know, I just googled it, which led to a tutorial and/or the relevant page of Apple's documentation.
In my experience, the best way to learn something like this is, well, experience.
Apple's documentation generally contains excellent API references, but (in my opinion) lacks equivalent topical guides. This makes it a bit hard to follow for beginners (Jacob Kaplan-Moss in the link I just gave makes the point that Python's documentation is like this, but I think Apple's is much more).
My recommendation would be to pick up Hillegass's book, alongside a project. The first few chapters explain fundamentals, so make sure to read those (and do the exercises!), or you won't be able to get far. Then try and implement your project idea; when you reach a wall, look through the Table of Contents and the glossary of the book and see if there's something that covers it. If you find something, use this as an excuse to read it fully and understand it. When you're finished, you'll have both a greater understanding and a project to show for it. Furthermore, you'll know what to search for in Apple's API references next time you try to implement something. This helped motivate me to finish the book, maybe it'll be helpful for you.[1]
[1]: (disclaimer: I have an odd learning style)

Open source Objective-C projects with high quality code?

I think one of the best ways to learn a new programming language is to dive into source code and see how experienced coders write. I've found this kind of question asked here on Stack Overflow for other languages, but none targeted at Objective-C. The closest I've found is this question about good-looking Cocoa user interfaces, but I'm thinking in terms of general code quality, such as good use of idioms and design patterns, and usable documentation. Another good characteristic would be a code-base that is large enough to require real organizational discipline, but small enough that a beginner can fit his/her head around.
What do you think is a high-quality open source project that meets these criteria?
There's a decent list of open source Mac projects on CocoaDev: http://cocoadev.com/CocoaOpen
Not all of the projects are still active, but a decent number of them are. I particularly recommend:
BWToolkit - http://bitbucket.org/bwalkin/bwtoolkit/
BGHUDAppKit - http://www.binarymethod.com/bghudappkit/
CHDataStructures - http://cocoaheads.byu.edu/code/CHDataStructures
MGTwitterEngine - http://mattgemmell.com/source
Sparkle - http://code.google.com/p/sparkleplus/
Colloquy - http://colloquy.info/project/wiki/Source%20Code
CocoaRest - http://github.com/sdegutis/CocoaREST
CorePlot - http://code.google.com/p/core-plot/
I've found Adium to be a well-designed and written Objective-C project. It has a huge codebase, too.
I don't think there's any one place to learn all the Objective-C idioms and best practices, but you can pick them up here and there over time and practice. Cocoa mailing lists and blogs are good resources for this. (There are several SO questions relating to that.)
I haven't dived into the source myself, but the Omni frameworks are well-respected in the Mac community.
I work on a framework of my own that's still rough around the edges, but I strive for quality documentation in addition to understandable, well-structured code.
Google Quick Search Box [ qsb-mac - Google Code ]
I think The Google Quick Search Box (QSB) is worth a look. IMHO it's pretty much a cleaner googley rewrite of Quicksilver (Note: N. Jitkoff, the QS programmer, is also involved in the Google QSB).
Apple has tons of downloadable examples on their developer website. You get to see the source, and the license is BSDish from what I recall (use it for whatever, but don't repost original code without the license).
http://developer.apple.com/samplecode/Cocoa/index-date.html
Check Out lots off open source project here.
http://code4app.net
http://code4app.com
https://www.cocoacontrols.com
Here's a test app I wrote earlier today. Download links under “get source” in the top-right.
It's small, but it demonstrates good organizational discipline (separate controller object, instead of everything crammed into AppDelegate), a simple model layer with one model class (Header), and correct use of Cocoa Bindings.
I used to work on the GNUstep sources, they've got a good consistent coding style and the code is well-organised. Of course the project is hardly small, but given that you know what most of the classes do as you've used them in your Cocoa projects it's easy to zoom in on a piece that interests you. Some of the GNUstep Applications Project or Étoilé apps may also be a good place to start.
Check out PSTreeGraph, a view control for iPad applications.
iMedia Browser
, shows support of 10.4 - 10.7 strategies, is neatly and purposefully organized, and deeply commented. inherent problems using ImageKit have been boldly approached and solved.
i aspire to this level of thought mixed with practicality.

Cocoa Applications Examples

I've been doing some cocoa since a week, and I'm getting kinda good with it.
I did some tutorials, calculators, currency converter, etc...
But I was wondering if there was any more advanced guide? Like build a RSS reader, or anything else... I dunno..
If you know any good resource for examples please tell me.
PS: I'm reading some cocoa books, and I'm learning from several sources like cocoa dev central, etc..
Thanks!
The cocoa examples at the apple developers connection are extensive and an excellent resource. Find them here
Another way of finding targeted example applications is from the Xcode documentation. Pick a class, for example NSTableView, and see what the related sample code shows;
Might be a better way than just picking examples at random.