Search
Powered by Squarespace
Stalk Richard

 
Article Topics
Sunday
Jan042009

NSConcreteAttributedString Ugliness

Ok I was struggling with updating a homegrown datasource for an NSOutlineView. What I ran into was that the method outlineView:setObjectValue:forTableColumn:byItem which you need to implement to capture the edits of an item gets passed in an (id)object in my case that is coming across as an NSConcreteAttributedString which is an internal class of NSAttributedString. Converting it and getting it back into my data source node was a little bit of bear. Here is what I came up with that works, though I haven't tested for memory leaks and such, and note I am using GC for this project.

- (void)outlineView:(NSOutlineView *)outlineView
setObjectValue:(id)object
forTableColumn:(NSTableColumn *)tableColumn
byItem:(id)item {
NSAttributedString *newattname =
[[NSAttributedString alloc] initWithString:[(NSAttributedString *)object string]];
[item setAliasName:newattname];
}
Tuesday
Dec302008

Lack of Control in OS X development

Yes this post contains a small rant. 

First though I have to say that I do love developing in Xcode / Objective-C and for the Mac in general.  It is a lot of fun, and frankly the results can be sexy as hell, however some of the challenges are just plain "bang you head against a wall" with no saving throw, madness.

[Rant on]

Need proof, well it is sort of hard to explain without detailed examples, but in general the greatest weakness I see is the lack of solid control development.

For example:  The delivered control for a Treeview (NSTreeController) quite frankly is probably (don't really have it working yet) one seriously powerful control.  However it is a real bear to setup, use, code against, etc.  Well in the PC world there are certainly corollaries, but the solution there is a provider, or super talent, wraps the power filled tool, in an easier to use control, and typically either gives it away for free (when they want Fame) or sells it (when they want fortune), but the gist is that the problem gets solved and a wider audience of developers can code applications against this.

[Rant Off]

This type of control level coding isn't a void in the mac world.  I have found a couple, my favorite so far is:

Brandon Walkin @ http://www.brandonwalkin.com

He seems to be in the category of doing it (for Fame) rather than (for Fortune), but seriously there needs to be like 1000's more like him rather than 1 or 2 scattered around the net.  

Here is hoping that these spawn up like wildfire, so that all developers don't have to dredge through the details.  If I can find time I think I will work a simpler Control for NSTreeView as a Sourcelist backed by a Core Data store, that is simple to utilize.
Monday
Jul142008

Challenge with calling SOAP services via Applescript

I recently had a need to call a SOAP service via applescript. Google to the rescue and I found several examples on the web. At first it appeared that there was an older technique which used sort of an Applescript to Perl bridge to call the service. Later it seems that there is a "call soap" routine built into the System framework on OS X and callable directly from applescript. This makes for some pretty simple looking applescript. I am struggling with issues however calling web services that where built on .NET frameworks. Something seems to be missing in terms of passing parameters to the web service.

Ok I put a log into the web service to watch what comes accross the wire, there's nothing like sniffing your own code :). The service was expecting this:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetRecordERD xmlns="http://bla.bla.bla/DUWSPSERD">
<STRRECORD>string</STRRECORD>
</GetRecordERD>
</soap:Body>
</soap:Envelope>


And applescript was actually sending something like this:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:GetRecordERD xmlns:m="http://bla.bla.bla/DUWSPSERD">
<STRRECORD xsi:type="xsd:string">JOB</STRRECORD>
</m:GetRecordERD>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Time for some more research.

Sunday
Jul062008

SWT StyledText SuperClass

I extended a superclass of StyledText to Add support for undo and redo operations.

First lets import a few things we are going to need:

   import java.util.LinkedList;
import java.util.List;

import org.eclipse.swt.custom.ExtendedModifyEvent;
import org.eclipse.swt.custom.ExtendedModifyListener;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Composite;


The LinkedList and List java.util routines are needed because our undo and redo additions are going to need a place to store on a couple of stacks the data to undo or redo. Lets start by creating a class "MyStyledText" that extends the SWT StyledText class.

public class MyStyledText extends StyledText {

private class undoRedoItem {
public Character Action;
public int Location;
public String Data;

public undoRedoItem(Character Action,
int Location, String Data) {
this.Action = Action;
this.Location = Location;
this.Data = Data;
}
}

 

Friday
Jul042008

Removed Joomla its back to Wordpress time.

I have removed Joomla and gone back to wordpress. It allows me to integrate [Textmate](http://macromates.com/ "TextMate — The Missing Editor for Mac OS X") with my blog and makes
for a very interesting easy to use system for posting blog entries about the software I am writing.