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

[Quickies]Getting UITextView to dismiss keyboard when the user hits the return key

No Comments

It might seem something simple, but I still remember when I was beginning my life as an iOS developer and certain things were not exactly out of the box. UITextView’s support for multiple lines puts it into a complicate situation when it comes to handle the return key. Still, that’s something you can easily implement using a delegate method.

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if([text isEqualToString:@”\n”]){

[textView resignFirstResponder];

return NO;
return YES;


Using native Objective-C code from UIWebView

No Comments

There are many of frameworks out there like PhoneGap that allow you to write iOS apps using HTML and Javascript. Even if you know Objective-C and/or SWIFT, sometimes a UIWebView might be useful. But what if you need to use functionality that’s not available on webkit? Creating a bridge between Javascript and Objective-C is easier than you think!

Open Xcode and create a new project.

Screen Shot 2015-05-23 at 5.16.03 AM


[Quickies]Making an iPhone vibrate

No Comments

Making an iPhone vibrate is very easy and takes only one function. The first thing you have to do is to import the AudioToolbox framework into your project and header file(s). That framework provides two functions you can use:


When the device does not support vibration(e.g. an iPod touch), the device will beep instead of vibrating. If it supports vibration, it will vibrate.


This function will vibrate a device that supports vibration. If the device doesn’t support it, it will do nothing.

Adding an external library on Android Studio

No Comments

When I started writing Android apps, I(just like everyone else) used Eclipse. Then Google released Android Studio, a whole new IDE designed for Android development. Things are obviously different from Eclipse. One of my first questions was “How do I import a library into my project?”. It turns out to be very easy!

To import a library click on File > Project structure.


Creating your first iOS app

No Comments

In this tutorial I’m going to teach you how to write your first iOS app(aka Hello World). I will assume you already know logic programming. If you’re reading this, then you’re probably not familiar with Objective-C and maybe even scared of it! Objective-C looks scary at first, but once you learn it, you won’t want to write code in any other language. It’s just easy, organised and readable. But why people find it so scary? Because of its unusual syntax! In Java, you’d write something like this:


In Objective-C, that would be:

[object method:argument];

It looks nothing like C, Java, PHP or other popular languages. But all you have to do is to open your mind and start from simple things, like this app I’m going to teach you how to write.


I’m on GitHub

No Comments

It toke a while to convince me to start using GitHub, but a few days ago a friend finally convinced me. I already published a few projects there and intend to publish a lot more. I will stop publishing open source projects on this blog(at least for now). Anyway, go check it out!

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;

[Open Source]FVGravityView

No Comments

Hey folks, I’m proud to announce my new open source project for iPhone. It’s called FVGravityView. It’s basically an UIView that has the ability to fall. Yes, fall. It uses the accelerometer to detect the device position and the view will fall depending on it. It’s basically an UIView that recognizes gravity.

A few thing:
-The default velocity is 20, but you may change this value by changing the velocity property.
-FVGravityView supports dragging. To enable it, set the property isDragable to YES.
-Say you want to invert the gravity. Just set the isInverse to YES.
-It’s basically an UIView, so you may add subviews to it. It also has every drawing capabilities that an ordinary UIView has.

To download the sample project, click here.

PS: I didn’t try it on an iPad, but it should work with no problems at all.

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:


Older Entries