Cocoa for Scientists
By drewmccormack at Mon, Jan 8 2007 4:41am
Author: Drew McCormack
Articles in this series include:
- Hello Brave New World
- Classy Cocoa
- Living Objects
- Good References
- It's All in the Genes
- Jekyll and Hyde
- Into Xcode
- IB, Therefore I am
- MVC is not the 'Motor Vehicle Commission'
- Popping Up All Over the Place
- The Value in Keys
- Observe and Learn
- In a Bind
- Beginning 3D Visualization
- Continuing 3D Visualization
- Finalizing 3D Visualization
- Representing Data in Tables
- Graphing Data with SM2DGraphView
- Telling Your Story with Narrative
- Python Scripters...Meet Cocoa
- Multi-threading Your App with NSOperation and NSOperationQueue
- Core Data Models
- iTunes-ifying Core Data Apps
- Core Animation First Steps
- Core Animation Layer Trees
- Parsing CSV Data
- Getting Closure with Objective-C
- Bonjour and How Do You Do?
- This is the Message
- Developing for iPhone
- All Aboard Grand Central
- The Physics of Sumos (A Flirtation with iPhone Game Development)
- 10 Uses for Blocks in C/Objective-C
- Scrapbook of an Advanced Core Animation View



Comments
Possible Cocoa for Scientists topic
Drew,
I find myself trying to reuse Obj-C classes and code, but I always run into the problem of how to do so cleanly. An example is, perhaps, writing a routine that has both code and IB resources such as a plotting library. Thus one would need (1) a graph view, with a frame and tic marks, presumably done in IB, (2) some routines for setting the graph properties, such as tic color or placement, presumably done in Xcode, and (3) some routines to plot data. All wrapped up in a nice reusable class, of course. I understand that a framework may be the cleanest way to do this, but the details of how to write and build a framework escape me despite a lot of reading. A graphing package is only one example of where a framework might be useful to a scientist. You use frameworks a lot in your examples, but might I suggest an installment or two on writing frameworks?
Thanks, Mark
Frameworks in Cocoa
Hi Mark,
Thanks for the suggestion. Code reuse is certainly an important topic.
Many people share small amounts of code these days simply as source files, and I actually find this the easiest way to incorporate third-party components. But if there are many source files, it may be worth building a framework. A framework is nothing more than a special target in Xcode.
In terms of designing frameworks, the main thing is to make as few assumptions as possible. Your code needs to work in a variety of settings, and with a variety of different classes. You need loose coupling, and you need to make sure there are 'hooks' in your code so that others can customize functionality. These hooks can include:
1. Methods that can be overridden in subclasses.
2. Notifications
3. Delegate methods
Writing a framework is generally more difficult that hacking together a piece of code that just needs to work well in one application. I think people sometimes underestimate how difficult it can be. For example, everyone seems to think Apple should have released an API for the iPhone by now, but to design that API to be flexible is not an easy task. Once you decide upon something in an API/framework, you can't go back easily in future. You have to make sure you cover as many bases as possible.
I'll think about how I could broaden this comment into an article in the series. Thanks for the feedback.
Drew
---------------------------
Drew McCormack
http://www.maccoremac.com
http://www.macanics.net
http://www.macresearch.org
Request
Hi Drew,
Thanks for all the tutorials. I enjoyed the tutorials with VTK.
I have a small request.
You know how programs like textmate and texshop compile tex in their apps.
How does this work? Does it include running command line commands in the app?
I was wondering if you knew and maybe could point me in the right direction. (if you have time)
Thanks again.
ken
NSTask
Hi Ken,
These apps will be running the external executable (command) as a subprocess. To do this, you can use the NSTask class.
I will try to write about this in a future tutorial, because it's something that is useful in scientific apps.
Drew
---------------------------
Drew McCormack
http://www.maccoremac.com
http://www.macanics.net
http://www.macresearch.org
ObjC vs. C++
This new registrant would like to add his sincere appreciation for the Cocoa tutorial and for MacResearch in general.
As a C++ (Carbon) developer, I procrastinated a *long* time before looking at ObjC because, IMHO, the loss of the STL and its derivatives (e.g., the Scythe Stat Lib) is very much a non-starter. Are you planning a chapter on combining ObjC and C++ for those out there like me? I suspect that there are some ;-)
Michael P. McLaughlin
Objective-C++
There is some documentation on combining Objective-C and C++ from Apple here.
Here is some sample code I was experimenting with that combines C++ and ObjC(it is not very clean, I will put up a cleaner version later). The code itself requires IT++, but it does show mixing C++ and ObjC.
Implementation file (.mm) here
Header file (.h) here
Regards,
Chinmoy
NSTask
Hello Drew,
Thanks for the excellent tutorials.
Regarding the above comments on NSTask, can this object be used, for example, to load a URL in safari or an image or pdf in preview? Is there a way of interacting with finder using Cocoa to obtain and display the thumbnail images for each file in a directory?
David Savage
David, for launching a web
David,
for launching a web page in your default browser, you could implemente the following code
NSURL *url = [NSURL URLWithString:urlString];
[[NSWorkspace sharedWorkspace] openURL:url];
if you want to open the link within your app, just create a webview kit. and use the following code
[webView setMainFrameURL:urlString];
for a PDF, I guess it will be similar to 'NSWorkspace' or if you want to embed it i your app, I would check pdfkit.
for the image question, sometime ago I read a blog where the author created an app similiar to the one you mention. just google it. if I remember correctly, he(she) uses NSBundle.
regards
SM2DGraphView IB Plug-in Failed
I was attempting to build the code in the Cocoa Tutorial (#18) but the instruction to install the SM2DGraphView.palette folder did not work with IB v3.1.1. The IB docs state that the plug-in format changed with IB v3 and that it and v2.5 are mutually incompatible.
I had planned to try Tutorial #19 next using Narrative. I built its Example (with a few warnings) and ran it successfully. Should I just skip #18 and move to #19 directly?
Or is there an updated #18 compatible with current Xcode and IB? [Mac OS 10.5.5, etc.]
TIA.
Michael P. McLaughlin
NSOutlineView tutorial
there are some fantastic tutorials on here, it would be fantastic if you were able to do a tutorial on implementing an NSOutlineView and the pros and cons of using an NSTreeController.
Keep up the good work! this is an amazing learning resource!
Great tutorial, I'm looking forward to learning and contributing
I am really enjoying this series of tutorials. I hope that by the time I get to graphing, I will be able to start a series of tutorials on coding DSP (digital signal processing) with Cocoa, which is my primary learning intention for reading these great articles. I can tell you right now, that doing mostly simulation engineering work and being a dedicated Mac user, my primary platform for research up until now has been MATLAB. C and C++ are good for programming chips, but they are terrible with any type of visualizations, since you have to code for hours (in the best case) just to give yourself a decent graphing environment. Cocoa has very neat tools for that, which can be used and abused to an advantage of any scientific coder. These tutorial and going in just the right direction so far and are very well written.
Thanks!
--
I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
- Albert Einstein
I could translate this tutorials into Japanese
Thanks Drew for this tutorials, I haven't read all off them yet but I think they are really useful!, (Also I didn't realize that you where the author of that book!)
I'been studying in Japan for 8 years now. I am a master engineering student and can write native level Japanese, so I thought I could translate this tutorials... I think this will be a big contribution!.
If I submit (Submit Story>Tutorials) them will they be available to everyone? or do I have to contact someone from Macresearch.org before?
Thanks again
Ignacio Enriquez.
Keio University - Japan
Re: Japanese
Having the articles in Japanese would be great. You can just submit the articles yourself. Let us know when you have a few posted, and we can draw attention to them.
Drew
---------------------------
Drew McCormack
http://www.mentalfaculty.com
http://www.macanics.net
http://www.macresearch.org
hi, you rock man! I've been
hi,
you rock man! I've been looking for this information for some time but its no where..at last I found this awesome blog.:)
------
http://www.hardgadgets.com
Thanks for all of the great
Thanks for all of the great tutorials Drew, they are a great read and are truly beneficial to all here. Keep up the great work.
My favorite was definitely #30, developing for iPhone. It was very beneficial and answered a lot of questions I had.
---
http://www.techorials.com
http://www.articlezz.info
http://www.webdesigncool.com
http://www.dailyautosblog.com
If you want to learn Online
If you want to learn Online Dating Tips then you can learn from here at free of cost www.myperfectbuddy.com
Also you can check here ho you can make new friends specially girl friends and many more.
Thank you for this nice
Thank you for this nice list.
It's 3 years old and still usefull!
_______________________
ferielejlighed gardasøen
Nice Script about the
Nice Script about the Education i hope more update news from you ASAP.
Thx a lot for the list,
Thx a lot for the list, you're awesome.
best hotel deals
The tutorials are great,
The tutorials are great, especially for newbies in the field. I have less than 2 years experience and am currently working on some apps designed to work from online storage servers.
Thanks! I have not much
Thanks!
I have not much experience but these are really useful for me. Thanks and best wishes.
chapter 7 bankruptcy information
chapter 13 bankruptcy information
I never thought that Apple
I never thought that Apple compilers are based on the compilers of the GNU Compiler Collection. I’ve read it from Mac OS Reference Library and it really has a wide array of documents intended for readers who are interested in Cocoa applications.
Adam Horwitz Mobile Monopoly Reviews Bonus
fantastic, thanksssss
fantastic, thanksssss :)
Posted by: bwin bonus
The Cocoa for scientists has
The Cocoa for scientists has been found to be very useful. The tutorials given are extremely helpful to the beginners. Some of the tutorials are Classy Cocoa, Into Xcode, Living Objects, Good References, into a bind, Observe and learn and etc. Nowadays the open source has created a sort of revolution. Everybody is ready to share their piece of code with others. That helps a lot of people. It is useful in making a framework. It is quite a difficult job. Sam|www.thecallcentergroupa-z.com