Well, for one you can only do it one handed!
Also you have to be ready for sudden lunges towards the keyboard. Bang bang bang go the keys. Oops a wrong click or an inopportune Enter and say goodbye to all that work.
Still it is nice for the little one to see what Daddy does all day, even if I have to spend most of the time stopping her from eating any CDs and other things I’ve foolishly left just within reach 😉
The monster child expresses her undying love for Daddy’s G5
I have to say that Cocoa bindings are one of the coolest things to some to Cocoa in a long time.
It takes a bit of getting used to however, and the documentation isn’t the greatest. One of the things that had me stumped for a bit was how to have a button‘s enabled flag depend on more than one edit field having a value. There was only one Enabled binding. It seems that Interface Build adds more Enabled bindings as you create them. So you add an Enabled binding, and all of a sudden in the bindings tab appears Enabled2. Add another one and what do you know Enabled3 magically comes into existence 🙂
I spent a little while looking to see if there was some way of doing something like Enabled = IsNotNull(field1) and IsNotNull(field2) and IsNotNull(field3), when all I had to do was just add them in.
It’s nice when the tools are smart like this, although it would also be nice if there was some documentation that said something like this would happen. I guess I should have know it would do that since it makes sense for it to do so. One of the nice things about Apple software is that it tends to just work (most of the time).
For a secret project I’m currently working on I needed to make a NSTextView that resized its contents so that it was always fully visible regardless of how many lines of text were in there. Coding something like that under Windows would have been pretty awful (especially since the text needs to still be editable), but cocoa made it a snap. Just make sure that the ratio of the control bounds and the parent controls frame is correct every time the text changes 🙂 The more I use cocoa, the more I want to use it, and the less I want to go back to other systems.
From what I understand the Microsoft .Net stuff would allow a similar approach, and the Java swing libraries would definitely allow it
It can be quite annoying when an application claims to support an API and actually doesn’t 🙁
I’ve been working on BlogThing off an on for about a week or so. Originally I used a bit of the metaWeblog API and a bit of the MovableType API. I’ve since standardized on metaWeblog and removed the references to MovableType. 🙂
Now, I’ve successfully tested BlogThing against WordPress and Typo however, Blojsom, while it claims to support the metaWeblog API it soon becomes apparent that this is not the case 🙁
NSTextView stores its data in a NSTextStorage object. NSTextStorage descends from NSMutableAttributed string, so that gives us a clue.
The easiest thing to do is to make a category on the NSAttributedString class to do whatever it is you want containing something like the following.
int L = [self length];
i = 0;
// get all the attributes we are interested in
NSDictionary* attributes = [self attributesAtIndex: i effectiveRange: &range];
NSAttributedString* attPart = [self attributedSubstringFromRange: range];
NSString* part = [attPart string];
NSFont* font = [attributes objectForKey: NSFontAttributeName];
NSColor* color = [attributes objectForKey: @”NSColor”];
NSParagraphStyle* paraStyle = [attributes objectForKey: NSParagraphStyleAttributeName];
NSShadow* shadow = [attributes objectForKey: NSShadowAttributeName];
NSURL* link = [attributes objectForKey: NSLinkAttributeName];
NSTextAttachment* attachment = [attributes objectForKey: NSAttachmentAttributeName];
// process your attributed string pieces here
i = range.location+range.length;