Getting your Mac to talk with NSSpeechSynthesizer

No Comments

When I got a Mac mini in 2008, one of the coolest things it could do was speaking. That is an accessibility feature, but not being disabled never prevented me from staying hours typing random stuff on terminal just to get to hear the computer talking.

It turns out we developers can use that feature too. And it just takes a few lines of code. Start by opening Xcode and creating a new project.

Screen Shot 2015-06-10 at 7.34.30 AM More

FVGetApp, an open source class to get and set default apps

No Comments

I’m pleased to announce the release of FVGetApp, an open source class to get and set default apps on Mac OS X. Say your Cocoa app needs to change the default browser. Not only FVGetApp can change it, but it also can get a list of apps that can handle the HTTP protocol. FVGetApp’s not limited to HTTP and HTTPS. It’s also possible to deal with any other protocol like mailto, ichat and ftp.

You can also deal with MIME types and extensions. So if you created an audio player and you want to let the user change the default app for MP3 files with a click, you will like my class too.

As a plus you can also check if an app can open a certain file.

I developed and tested it on Mountain Lion, but it should work on previous versions of Mac OS X. Adapting it to non-ARC code would take less than 1 minute. You can download a ZIP file containing the class, documentation and a test app by clicking here. To help you to understand the capabilities of this class before downloading the ZIP, here’s a method list:

+(BOOL)isAppCompatible:(NSURL *)appURL withFile:(NSURL *)fileURL;
+(NSDictionary *)appForProtocol:(NSString *)protocol;
+(NSDictionary *)appForMIMEType:(NSString *)MIMEType;
+(NSDictionary *)appForExtension:(NSString *)extension;
+(NSArray *)allAppsForProtocol:(NSString *)protocol;
+(NSArray *)allAppsForMIMEType:(NSString *)MIMEType;
+(NSArray *)allAppsForExtension:(NSString *)extension;

New MacBook Pro

No Comments

My old MacBook Pro ain’t working properly, so I got a new one. This time, I got the unibody model. Yeah, it’s second hand, but it’s still a great machine. The screen is INCREDIBLY amazing! The speakers are also very cool. :)


Yeah, I will try to fix my old MacBook Pro soon.

And I’m back to Snow Leopard

No Comments

I know Mountain Lion was released a couple days ago, but I ended up downgrading my MacBook Pro to Snow Leopard. Lion is just too buggy. I never thought I’d say that, but even Windows Vista is better. It’s buggy, slow, ugly and consumes a lot of memory. And is there anything new on Lion that’s relevant? No! Just a mobile interface on a desktop, and let’s face it, it doesn’t work work. Snow Leopard is far better than Lion. Mountain Lion won’t run on my Mac without a workaround. But the main reason to not install it at this moment is that it probably has a lot of bugs considering it’s a .0 version. I also kept Tiger on another partition, as I’m a big fan of that OS. This time, the Tiger partition is a half of my hard drive. And yes, I still use it regularly. Mainly to work on a Mac app that should be out soon. I really wanna make it compatible with Tiger and Panther.

RIP Sensitive Code

No Comments

Hey folks, unfortunately, my blog Sensitive Code is dead. I had no time to update it and ended up not renewing the domain registration. It had a great page rank. For example, if you type UIFileSharing on Google, a post from Sensitive Code it is the first result(not sure for how long). I moved every post from there to this blog, so everything is still available. I hope to write about programming on this blog in the future.

Easy multithreading, a courtesy of NSOperation

No Comments

Threading is known for being very hard in any language. A foolish mistake can make your application crash. Programmers spend a lot of time to make sure everything works fine. On Mac OS X 10.5, Apple finally introduced a very easy way to deal with threading. NSOperation is The Apple Way® to deal with threading. All you have to do is to subclass the NSOperation, create and initialize a NSOperationQueue, create and initialize the NSOperation and add it to the NSOperationQueue. For this tutorial, I will teach you how to write a simple app that will load a RSS feed and display it on a NSTableView.

To get started, go to Xcode and create a new project. I will call mine RSS Reader, but feel free to call it whatever you want. Let’s start by editing our AppDelegate.h. Create 3 IBOutlets:


[Book]Cocoa Programming for Mac OS X

1 Comment

People ask me very often what they should do to get started in programming. I usually tell them to read books. And what’s the best book for those who want to learn Mac programming? It’s Cocoa Programming forMac OS X by Aaron Hillegass. This book is the best, it simple defines what we are, it’s our bible. The book considers you already know a little C or C++ and teaches you everything a decent Mac developer should know: from a hello world to printing, web services and Core Animation.

The guy who wrote this book can be considered the world’s best Cocoa teacher. He taught Objective-C at companies like Intel, NeXT, Apple and Microsoft. He is also the own of Big Nerd Ranch, a very famous training center.

Now let me tell you guys about my faith testimony. I started to try to learn Cocoa in the beginning of 2008, I had gave up and started to look for alternatives to Objective-C. I mean, that syntax looked so weird. A very long time after that, in the end of 2009, Lars Bergstrom told me about this book. In less than a month I was writing my first commercial app.

At the time I’m writing this, it costs $30.24 USD on Amazon. It’s not the world’s cheapest book, but it isn’t the most expensive one. It’s worth investing on a copy. Get it on Amazon.

Share and Enjoy:

[Quickies]Opening URLs in external applications

No Comments

Opening URLs on external applications is easy, no matter if you’re on an iPhone/iPod touch/iPad or on a Mac. On the Mac, we’d do something like this:

NSURL *URL = [NSURL URLWithString:@””];
[[NSWorkspace sharedWorkspace] openURL:URL];

Simple, uh? Now let’s see how to do this on the iOS:

NSURL *URL = [NSURL URLWithString:@””];
[[UIApplication sharedApplication] openURL:URL];

Easy peasy :)

FVImageSequence for Mac OS X/iOS


When I got to know Rainer Brockerhoff, one of my first questions was about networking. One of his advices was to write some open source code. A few days ago I was working on my customer’s app. He needed something similar to Apple’s 360° demo. I did not want to do that on a UIWebView as the performance is not the best. After looking for a view that does that, I found there was no one available. So I decided to write my own. Now I’m releasing it as an open-source project. The first of many.

FVImageSequence is basically a subclass of NSImageView/UIImageView that allows you to create the 360° effect by using a sequence of images. To use this view, you will have to add a image sequence to your project. All images must have the same prefix(i.e. myimage0.png, myimage1.png, myimage2.png). Set the prefix of the images you want to use by setting the prefix property.

You must also set the number of images. Just set the numberOfImages property in order to do that.

Also, don’t forget to set the property extension with the extension of the files(i.e png, jpg, gif).

Optionally you might set the increment property. This property basically tells the view how many images it should increment. If instead of incrementing 1 image, you want to increment 5, just set it to 5.

If you’re using the iOS version, don’t forget to enable the user interaction on Interface Builder.

Download the source code and the sample project from this link.

R.I.P. Steve Jobs

No Comments

I still can remember when I first heard about Steve Jobs. That was in 2007 when I was reading a Wikipedia article about Apple. Rest in peace, Steven Paul Jobs.


Older Entries