Saturday, June 23, 2007
Closing Down
Since I am now the sole owner of Potion Factory, I will be doing my blogging at the
company blog. If you are subscribed to this blog, please unsubscribe as this site will be going away eventually.
Sunday, January 7, 2007
My MWSF Prediction

Just practicing with my new Wacom Intuos3 tablet.
Thursday, January 4, 2007
WriteRoom Drama
I have never corresponded with Jesse Grosjean of Hogbay Software before, but I want to congratulate him on the release of WriteRoom 2.0. It looks like a fantastic application.
What got me blogging about WriteRoom though is a post on Jesse's blog where he explains the new $25 pricetag of a previously free application in response to an angry comment on VersionTracker.
But then I started reading comments on some popular download sites... ouch. The basic thesis is that WriteRoom is a great program, but I'm an evil person for charging $25 dollars for it. And once I'm evil a few other comments concerning Mori and Hog Bay Software in general are thrown in.
I'm not sure that I can make those people happy, but here I'll at least try to explain myself and the pricing of WriteRoom.
Link to Jesse's post, "The life and drama of a Mac shareware developer"Labels: application, cool
Monday, January 1, 2007
Xcode Feature Request
I really want to use Xcode to edit Objective-C. I desperately want to. Xcode 3 comes closer to being a usable editor, but I really wish that Xcode had the following feature:
I never liked navigating around the brackets in Objective-C, so this was something I hacked into Emacs pretty early on while adapting to Cocoa.
On the topic of editors, there's a cool editor for Scheme called DivaScheme. It's heavily influenced by vi and it makes navigating through code a breeze. Much of what is cool in DivaScheme is possible because Scheme and Lisp's syntax is so minimal, but I don't see why the concept can't be applied to Obj-C as well. If you are planning to write Yet Another Text Editor, please do us all a favor and click the link below. The page has a short video tutorial.
Link to DivaScheme
Friday, December 29, 2006
Syntactic Sugars
I have a sweet tooth for syntactic sugar. I love things like mystring[-1] in Python. Just like real world sugar, too much syntactic sugar can ruin the health of a programmer, but in moderation, it's a wonderful thing.
Naturally, I was overjoyed to learn that Objective-C 2.0 in Leopard will bring property accessors and foreach style loops. This is all good except that in order to take advantage of these 1999 technologies you have to target Leopard. While not a problem for people developing new applications, it's a huge tease for the rest of us.
So what's a programmer to do? Well, at Potion Factory we actually have had accessors and foreach loops for a while now. The solution involves lots of macros and it's of course nothing like what you get with Obj-C 2.0, but it still saves us an enormous amount of typing.
Foreach style loops
After having programmed in Python for a while, I found the following enumeration idiom in Objective-C to be rather painful, to put it mildly.
NSEnumerator *e = [collection objectEnumerator];
id obj;
while (obj = [e nextObject]) {
// do stuff with obj
}
I can't believe it's not butter... or Java...
Luckily I found the following foreach macro somewhere in the cocoa newsgroup.
#define foreach(element, collection) \
for (id _##element##_enumerator = [collection objectEnumerator], element; \
element = [_##element##_enumerator nextObject]; )
It simplifies the enumeration down to the following bit of code
foreach (obj, collection) {
// do stuff with obj
}
More than just taking out two lines of code, this drastically improves the readability., It also saves you from typing the same thing mindlessly over and over throughout the day.
Later on I found out that the foreach macro has been discussed by
Jonathan Rentzsch,
Michael Tsai, and
Wincent Colaiuta. Jonathan has a type-safe version where you specify the object type in the loop to get compiler warnings and Michael's implementation does IMP-caching to speed up calls to -nextObject.
Accessors
// For interface
#define GETTER_H(type, attr, capattr) \
- (type)attr;
#define SETTER_H(type, attr, capattr) \
- (void)set##capattr:(type)value;
#define ACCESSORS_H(type, attr, capattr) \
GETTER_H(type, attr, capattr) \
SETTER_H(type, attr, capattr)
// For implementation
#define MYASSIGN(old, new) \
if (old != new) { \
[new retain]; \
[old release]; \
old = new; }
#define GETTER(type, attr, capattr) \
- (type)attr { return m##capattr; }
#define SETTER(type, attr, capattr) \
- (void)set##capattr:(type)value { MYASSIGN(m##capattr,value); }
#define ACCESSORS(type, attr, capattr) \
GETTER(type, attr, capattr) \
SETTER(type, attr, capattr)
The macros above allows us to define and implement our accessors the following way:
@interface Person : NSObject {
NSString *mName;
}
ACCESSORS_H(NSString*, name, Name);
@end
@implementation Person
ACCESSORS(NSString*, name, Name);
@end
We use various flavors of the above macro and it allows us to develop our applications much faster. Again, it improves readability and eliminates much typing. The (f)ugly part is having to type the variable name in both lowercase and capitalized forms. If you know how that can be avoided, please let me know.
The time savings become quite significant when you apply the idea to Core Data's managed object subclasses.
ManagedObjectAccessors.hLabels: cocoa, code
Tuesday, December 26, 2006
Hello, World!
Ah, it's the end of the year. It's time for the festivities, wonderful gifts, getting drunk, and making resolutions (while drunk?) that usually last a month at best. My new year's resolution this year is becoming the most famous Andy Kim in the world. How the heck do you measure famousness? With Google pagerank of course. There are a lot of Andy Kims in the world, with 99.999% of them being of Korean descent, but
right now the top position is held by the Canadian singer and song-writer famous for the 70's hits such as
Baby I Love You and
Sugar, Sugar. With this blog I intend to beat the singer to become the most famous me there is. I figure that if this doesn't work, I'll start uploading videos to YouTube as lonelykim15, but I am hoping that it doesn't have to come to that.
By the way, I do realize that this is juvenile and narcissistic, but before you pass judgement, just take a look at
this photo and tell me that you would want that to be the first hit on your name search. In this day and age where people—say, a blind-date, for example—google your name, these things become important.
All jokes aside, here I will rant about stuff that interest me—such as, the Mac, programming on the Mac (with Cocoa mostly), running a Mac ISV called Potion Factory, stuff relating to design, and maybe even boring personal stuff from time to time.
Welcome to my blog and I hope to see you around.