Daily Archives: March 26, 2007

Any comments?

Anybody reading my blog care to comment? Perhaps there are some Mac programming topics you would like to know more about(or even programming in general)? Feel free to ask.

Grokking Core Data

I went through this video tutorial on Apple Developer’s site. It is fairly basic, but it shows how one can get powerful functionality with very little code(Core Data, for those who don’t know it, “allows any sort of data organized by the relational entity-attribute model, to be serialized into XML, binary, or SQLite stores. The data can be manipulated using a higher level set of objects representing entities and their relationships.”–Wikipedia ).

Another way to think about this is the incredibly popular Model-View-Controller design pattern. You specify the model graphically in Xcode, set up the view using Interface Builder, instantiate controllers in Interface Builder and bind the views to the controllers you just instantiated. Of course, in a non-trivial application that handles a lot of data, you will want to programmatically process some data–I think the easiest way to think about this programmatic control is through Apple’s NSPersistentDocument tutorial.

Last, but not least, an excellent way to gain deeper information about Core Data is to read Mr.Scott Stevenson’s “Core Data Class Overview” article. The format is excellent and the article is full of illustrations that literally help one understand the “big picture”.

Wrapping a CLI with Cocoa–Final Comments

Update: I have found a better way. See this post.

So, probably the easiest way (even if somewhat pokey) to wrap a CLI program with a Cocoa GUI is to use AppleScript as the bridge. For example:

do shell script “cd /Xcode_projects/Debug; ./sample > result.txt”

is the contents of a sample applescript, where result.txt is the output of the CLI, sample is the name of the CLI program. One would use NSTask to run the applescript(in order to run the CLI and generate output).