eval(art);

Languages

Logitech LCD Framework for G Series Keyboards

by Philippe Hausler on Jul.14, 2009, under MacOS X, Objective-C

Here is the latest rendition of the LogitechLCD.framework now with Interface Builder support and automatically updating views for devices. Additionally there is a screencast to give a brief tutorial on how to use the framework and the Interface Builder support.




Download the Logitech LCD Framework

Comments Off more...

G Series Keyboard LCD Framework

by Philippe Hausler on Jul.12, 2009, under MacOS X, Objective-C

I just recently purchased a G13 keypad. I fell in love with the scriptability of it, but longed to be able to add application support to it. Sadly the Logitech SDK that is shipped is a bit on the mangled side and does not play well with threaded applications. So I ventured to write my own version.

The framework binds the c library for the device but skips out on the “EZ-LCD” c++ stuff… the framework does not pose any obj-c++ requirements on any handlers. Additionally the display architecture implements notifications of key events, and is built to be very similar to AppKit (methinks maybe Interface Builder extension in the works?)

I will post a tutorial once I finish testing for bugs.

But if you like, here is a beta version that works for text, images, and progress bars plus events for the soft keys, applet, and device.
LogitechLCD.framework

Comments Off more...

MySQL.framework for iPhone

by Philippe Hausler on Jun.22, 2009, under Database, MySQL, Objective-C, iPhone/iPod Touch

As shipped XCode does not have any native method to compile Framework targets for iPhone, however for a project I have been working on there has been a very strong need to create an embedded framework suitable for iPhone/iPod Touch targets. So after a few days of tinkering with some internals of XCode I have created a method that will do just that!

Sincere I have gotten a decent amount of “buzz” for porting libmysqlclient to the iPhone OS; That is my first target to try out.

So with out further ado I present
MySQL Framework for iPhone

This is currently an alpha version of a full fleged framework for iPhone/iPod Touch 3.0. More documentation will be coming shortly. Do note this is not yet intended to be used for production software and is merely a proof of concept for embedded frameworks. Many features are missing from the obj-c abstraction for MySQL and the client is based on libmysqlclient 5.0.67 which is NOT up to date. However tests have shown capabilities of basic connectivity, authentication and queries to 4.1.22, 5.0.45 and 5.1.30 community editions (note no enterprise connections have been tested as of yet).

USAGE

In order to properly compile apps using the MySQL.framework a few preperation tasks need to be done.

Setup two targets, one specified for iPhone Device 3.0 and one specified for iPhone Simulator 3.0

Add the MySQL.framework from the Device folder as a framework to the Device target.

Likewise add the MySQL.framework from the Simulator folder as a framework to the  Simulator target.

Add a Copy Files Build Phase to both targets specified to the type Framework.

Add the respective frameworks to those Copy Files Phases.

Make sure that both targets are using Base SDK in order to allow the compile target to specify the SDK (and frameworks used).

Comments Off more...

LuaKit

by Philippe Hausler on Apr.09, 2009, under Lua, MacOS X, Objective-C

Lua is definitely one of the most powerful and easy to use scripting languages out there. Unfortunately the api caters to c, there are a few libraries out there that implement c++ bindings for Lua, but none that implement the state handlers in obj-c. Until now.

LuaKit.framework is a fully contained lua api for obj-c, it allows base accessors to the stack via NSString, NSNumber(NSUInteger/NSInteger as well), and also allows pushing obj-c “closures” (aka selectors to an object, NSInvocations) to give the developer a seamless transition from obj-c interfaces to the Lua stack.

This project is licensed as GNU LGPL so feel free to integrate it in your app. Please make sure to give me credit, but hopefully it will aide in producing some killer scriptable apps.

Examples coming soon.
Google Code Project Page

Download LuaKit.framework

Comments Off more...

FoundationAdditions.framework

by Philippe Hausler on Apr.03, 2009, under MacOS X, Objective-C

Why doesn’t Foundation allow for runtime abstraction into Objective-C classes?
Why doesn’t Foundation have STL like classes for lists, deques and queues (more than NSSet, NSArray, and NSMapTable)?
Why doesn’t Foundation have regular expressions for strings?
Why doesn’t Foundation have tcp sockets as a more compatible version than NSSocket?
Aren’t base Foundation classes like, NSArray, NSString, NSData etc missing a ton of handy/commonly re-used functions?

Well now it can! Introducing FoundationAdditions.framework: a collection of classes and extensions to the base Foundation framework allowing all the way from adding unique objects to a NSMutableArray to the objective-c runtime as an abstraction to objective-c objects to STL classes implemented in objective-c (not objective-c++ btw) classes.

This is however not a complete framework yet, its missing a fair amount of commentary and usage examples. So please consider this as a work-in-progress. Most of the classes have been tested, that being said there may be some memory leaks/bugs etc.

Download FoundationAdditions.framework

Comments Off more...

SQLite.framework

by Philippe Hausler on Mar.31, 2009, under Database, MacOS X, Objective-C, SQLite

Wouldn’t it be great to be able to access SQLite databases with just Objective-C calls?
Now you can with SQLite.framework. This framework supports NSFastEnumeration on SQLiteResults as well as per result enumeration. Additionally the database connections provide update callbacks into the database delegate object.

Here is some example usage.

SQLiteDatabase *db = [SQLiteDatabase databaseNamed:@"mydatabase.db"];
if([db executeQuery:@"CREATE TABLE foo (bar TEXT, baz NUMERIC, car INTEGER, caz BLOB);"])
{
    [db executeQuery:@"INSERT INTO foo VALUES('500.0', '500.0', '500.0', '500.0');"];
}
for(NSDictionary *row in [db executeQuery:@"SELECT * FROM foo"])
{
    NSString *bar = [row objectForKey:@"bar"];
    NSNumber *baz = [row objectForKey:@"baz"];
    NSNumber *car = [row objectForKey:@"car"];
    NSData *caz = [row objectForKey:@"caz"];
}

Download SQLite.framework

Note: This framework is still fairly un-tested and a bit on the alpha side, however future releases may add features like query building and detailed table/row/record information. Additionally I am creating a SequelPro-like client app to demonstrate the framework and provide an easy tool to manipulate SQLite databases.

Comments Off more...

Cocotron; Spreading the joy of Cocoa to Windows

by Philippe Hausler on Dec.07, 2008, under Objective-C

Many developers like myself are writing software in totally independent IDEs and usually with totally independent languages to release software for Windows and Mac OS X. There have been many attempts at making methods to accomplish one unified IDE and language to release multi-platform software. However to take advantage of many of the more modern features of operating systems, developers are locked into a proprietary language. Cocotron offers a potential at a fully universal development platform. Unlike the other “solutions”, Cocotron offers a fully binary and C level compiler to target cross platform build results. Hopefully this project will attract enough attention to create a buzz for Apple to snatch this up. One API, one set of application code, one language to rule them all.

Comments Off more...

Cocoa TCPSockets

by Philippe Hausler on Dec.05, 2008, under MacOS X, Objective-C, iPhone/iPod Touch

Unfortunately Cocoa does not have native sockets that are universal enough to connect to other language built applications as a pre-built class. The server is intended to be a more thematic method for creating a server in Cocoa than the alternatives. The primary mechanic for connections being established, data incoming and connections closed are all based on delegate notifications by the TCPServerDelegate and TCPServerConnectionDelegate protocols. Data buffering, packet encapsulation and reachability are all upon the host application’s responsability to deal with. The server class set is intended to handle opening a TCP port for hosting, creating new connections to that TCP port, sending/receiving raw data, and Bonjour broadcasting. The TCPClient class also bends BSD sockets to preform similarly. The end result is a simple, easy to use socket server and client class which is portable from Mac OS X desktop to iPhone/iPod which can connect and transact with other applications such as software written for Windows.

Here is an example of a simple chat server.

@implementation TCPChatServer
- (id)init
{
	self = [super init];
	server = [[TCPServer alloc] init];
	server.delegate = self;
	[server listenOnPort:5543];
	[server broadcastOnDomain:@"" type:@"_tcpchat._tcp" name:@"My Chat Server"];
	[server publish];
	return self;
}
- (void)server:(TCPServer *)aServer didAcceptConnection:(TCPServerConnection *)aConnection
{
	aConnection.delegate = self;
}
- (void)connection:(TCPServerConnection *)aConnection didReceiveData:(NSData *)data
{
	[server write:data excluding:aConnection];
}
@end
 
@implementation TCPChatClient
- (id)init
{
	self = [super init];
	client = [[TCPClient alloc] init];
	client.delegate = self;
	return self;
}
- (void)connectToServer:(TCPHost *)host
{
	[client connectTo:host];
}
 
_ (void)send:(NSString *)msg
{
	[client write:[msg dataUsingEncoding:NSUTF8StringEncoding]];
}
 
- (void)client:(TCPClient *)aClient didReceiveData:(NSData *)data
{
	NSString *msg = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
	NSLog(msg);
}
@end

TCPSockets.zip

Comments Off more...

Lua XHttpRequests v0.1b

by Philippe Hausler on Oct.11, 2008, under C, Lua

LuaXHttpRequest

local req = XHttpRequest.new();
XHttpRequest.open(req, "GET", "http://www.anothertest.com/search.xml?searchQuery=Mytest&searchType=all");
local result = XHttpRequest.send(req, null);
print(result);
Comments Off more...

UITableViewCell Templates

by Philippe Hausler on Aug.29, 2008, under Objective-C, iPhone/iPod Touch

Interface Builder by far is probably one of the easiest user interface design applications I have used. It is wonderful for rapid application design not only for Mac OS X but also iPhone. Unfortunately it still seems rather limited in some respects for the newly released iPhone SDK. Namely table cells still have to be hard programmed into your application and no layout management is directly available through Interface Builder.

This doesn’t have to be the case. There is a native UI object for UITableViewCells in Interface Builder just no way of directly formatting the table like the way Mac OS X applications are handled for tables.To get around this a subclass of UITableViews has to be made to allow a IBOutlet to a cell template.

@protocol AdvancedTableViewDelegate
@optional
- (void)tableView:(UITableView *)tableView didDeselectRowsFromTouches:(NSSet *)touches;
@end
 
@interface AdvancedTableView : UITableView {
	IBOutlet UITableViewCell *cellTemplate;
}
@property (nonatomic, retain) UITableViewCell *cellTemplate;
@end
@synthesize cellTemplate;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
	BOOL isCellTouch = NO;
	for(UITouch *aTouch in touches)
	{
		if(aTouch.view != self)
		{
			isCellTouch = YES;
		}
	}
	if(!isCellTouch)
	{
		if([self.delegate respondsToSelector:@selector(tableView:didDeselectRowsFromTouches:)])
		{
			[self.delegate performSelector:@selector(tableView:didDeselectRowsFromTouches:) withObject:self withObject:touches];
		}
	}
	[super touchesEnded:touches withEvent:event];
}

Furthermore, the native table view has no notification or delegate protocol to alert the delegate of a UITableView that the selection has changed to nothing. Since events bubble much like the concept of DOM events, the table views can capture the touch events and test to see if they are either to a cell or not. If the touch event is not a cell, most assuredly the event is indented to deselect the current table selection. Also accessor methods will need to be implemented to allow the table view to reference the assigned template from the xib.

@implementation  UITableViewCell (Copying)
- (id)copyWithZone:(NSZone *)zone
{
	UITableViewCell *copy = [[[self class] allocWithZone:zone] initWithFrame:self.frame reuseIdentifier:self.reuseIdentifier];
	copy.textAlignment = self.textAlignment;
	copy.image = self.image;
	copy.selectedImage = self.selectedImage;
 
	copy.accessoryType = self.accessoryType;
	copy.accessoryView = self.accessoryView;
 
	copy.indentationLevel = self.indentationLevel;
	copy.indentationWidth = self.indentationWidth;
 
	copy.textColor = self.textColor;
	copy.selectedTextColor = self.selectedTextColor;
 
	copy.shouldIndentWhileEditing = self.shouldIndentWhileEditing;
	copy.showsReorderControl = self.showsReorderControl;
	[copy addSubview:[self.contentView copy]];
 
	return copy;
 
}
@end
@implementation UIView (Copying)
- (id)copyWithZone:(NSZone *)zone
{
	return [NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:self]];
}
- (id)firstSubviewOfClass:(Class)aClass
{
	for(id subView in self.subviews)
	{
		if([subView class] == aClass)
		{
			return subView;
		}
	}
	return NULL;
}
- (id)subviewAtIndex:(NSUInteger)index
{
	return [[self subviews] objectAtIndex:index];
}
@end

With these two extensions to the base views, table rows can now be rendered on the fly as copies of the original UITableViewCell template assigned to the table view. WARNING: Make sure to set the identifier in the UITableViewCell template object to the identifier specified in the table rendering code! Unfortunately any connections, bindings or actions will be lost in this copy so they will need to be remade programmatically.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	NSInteger index = [indexPath indexAtPosition:1];
	static NSString *MyIdentifier = @"MyIdentifier";
 
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
	if (cell == nil) {
		cell = [[(AdvancedTableView *)tableView cellTemplate] copy];
	}
	[[[cell subviewAtIndex:1] firstSubviewOfClass:[UILabel class]] setText:[testData objectAtIndex:index]];
	[[[cell subviewAtIndex:1] firstSubviewOfClass:[UIProgressView class]] setProgress:[[testProgressData objectAtIndex:index] floatValue]];
	return cell;
}

Since the cell creation and rendering method does not have the table passed as a subclass the object must be typeclassed. When referencing the subviews one must also be warry that the order of render defined in the xib file is going to most likely be the order that is in the actual rendered cell (this may not be the case if the cell has any children that are programmatically made). This method is also interoperable with the standard methods of creating cells, however if the cell is a subclass, any connections are lost.

Comments Off more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...