April 11, 2009 | Filed Under Cocoa | No Comments
In a time of REST protocols… I still love the Binary Communication. I don’t have much ideas this period, I need to find a different job (C# doesn’t fit my code necessity). The Example Source code, contains two Folder. One is the Qt4 TcpServer the second one is the ugly application that you can see below
Note: This example doesn’t have anything related to the Qt 4.5 Cocoa Support.
Run the Qt4 Server, and the Cocoa Application (Remember to change the SERVER_HOST in AppController.m) and try to send some binary data. The Qt Server will receive this data it will resend you. Protocol is Very easy 1 byte of Data Type (Int8, Int16, ..) and Data. Remember that Intel arch is Little Endian.

Note: This is just a “Draft” a “non complete” example only to give the idea on how it works.
The Source Code is available here: Qt/Cocoa DataStream Source Code.
March 8, 2009 | Filed Under Cocoa | 13 Comments
Do you remember the Cocoa Sidebar? No, Take a Look at this post Cocoa Sidebar with Badges.
Joel asked me to revise the Sidebar, allowing to add/remove and do other operation at any time.
I’ve rewritten all the code of the Sidebar, and I’ve added a couple of new features, like the default action handler and obviously the ability to add, remove items and badges at any time.
All the past features, like Drag & Drop are still present, but there’s something else to do to improve it. If You’ve suggestions, patches or something else post a comment or send me a mail!
The Source Code is Available Here: Cocoa Sidebar 2 Source Code.
Update 10 March 2008 – Source Updated with Fixes.
February 28, 2009 | Filed Under Cocoa | 1 Comment
Today a simple example of Drag & Drop with Cocoa and NSView. The screenshot below shows two groups. In the first one, you can drop the photos on your filesystem, taken from Desktop or Finder. In the second group, you can only drop the first group image.

You can find the source code here: Drag & Drop Test Source Code.
February 1, 2009 | Filed Under Cocoa | No Comments
Following the Google StreetView post, another example on How Cocoa Application can Interact with Google. Today the WebKit shows Google Maps.

Like iPhoto ‘09 you can select you Map Type (Terrain, Satellite, Hybrid) and you can Zoom In or Zoom Out using controls of your Application.

You can Find the Source Code Here: Cocoa Google Maps.
January 17, 2009 | Filed Under Cocoa | 2 Comments
Last iPhoto ‘09 presented at MacWorld contains a couple of interesting Features: Faces and Places. Today, I’ve a little bit of free time to play with my Mac, and the topic is How to embed Google StreetView into a Cocoa Application.

The Solution is using WebKit and Google Maps API. We’ve a simple HTML file that contains StreetView “Canvas” and a couple of javascript methods that interact with GStreetviewPanorama Object.

The Source Code is Available Here: Cocoa StreetView Source.
December 6, 2008 | Filed Under Cocoa | No Comments
Today I’ve played a bit with WebKit. I Want do something like Cocoa VBox View and NSScrollView but with more flexibility. Below you can see the example result.

The interesting part of this example is How to manage WebKit content, and how to add something dynamically.
I use webView:decidePolicyForNavigationAction:request:frame:decisionListener: of WebPolicyDelegate Protocol to handle my custom requests, in this way…
- (void)webView:(WebView *)sender
decidePolicyForNavigationAction:(NSDictionary *)actionInformation
request:(NSURLRequest *)request frame:(WebFrame *)frame
decisionListener:(id)listener
{
if ([[[request URL] path] isEqualToString:@"PATH to Handle"]) {
[listener ignore];
// Handle Request
} else {
[listener use];
}
}
…Then with a little bit of JavaScript I’ll set my dynamic content loaded from Database or somewhere else.
NSArray *args = [NSArray arrayWithObjects:@"Item1Content",
@"Hi, I'm Test 1 Content", nil];
[[webKit windowScriptObject] callWebScriptMethod:@"fillElement"
withArguments:args];
The fillElement method is a simple JS function like this document.getElementById(elem).innerHTML = data;
Here you can find the Source Code.
December 2, 2008 | Filed Under Cocoa | 8 Comments
Yesterday, I’ve written a simple Sidebar controller that can saves you some time and trouble with Cocoa Source List. Nodes and Folders can be drag and dropped into other folders or near other items and you can easily set badges on nodes.

Cocoa Sidebar
You can find the example Source Code Here.
And below you can see hot to add folders, nodes and set badges.
- (void)populateOutlineContents:(id)inObject {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[sidebar addRootFolder:@"1" name:@"DEVICES"];
[sidebar addChild:@"1.1" name:@"Machintosh HD"
icon:[NSImage imageNamed:NSImageNameComputer]
action:@selector(buttonPres:) target:self];
[sidebar addRootFolder:@"2" name:@"PLACES"];
[sidebar addChild:@"2.1"
url:NSHomeDirectory()
action:@selector(buttonPres:) target:self];
[sidebar addRootFolder:@"3" name:@"OTHER."];
[sidebar addChild:@"3.1" name:@"Bonjour"
icon:[NSImage imageNamed:NSImageNameBonjour]
action:@selector(buttonPres:) target:self];
[sidebar addChild:@"3.2" name:@"Users"
icon:[NSImage imageNamed:NSImageNameUserGroup]
action:@selector(buttonPres:) target:self];
[sidebar clearSelection];
// Add Badge to Node with Key
[sidebar setBadge:@"2.1" count:5];
[sidebar setBadge:@"3.2" count:7];
[pool release];
}
- (void)buttonPres:(id)sender {
NSLog(@"Button Press %@", [sender nodeTitle]);
}
November 16, 2008 | Filed Under Cocoa | 1 Comment
Following the post of yesterday, today I’ve implemented a simple VBoxView (Vertical Box Layout) that allow you to lines up NSViews vertically.

Cocoa Scrollable NSViews VBox
Here you can find the example
Source Code.
Next Page »