Recordium is now on AppStore top charts!

Recordium is one of the apps we’re working on at Pichak. It’s getting more and more popular everyday, because users love its unique features. Yesterday we’ve celebrated its first birthday. One year ago, the Recordium released to help users record their moments. It makes it easier to record your voice memos and annotate them at the same time.
10359030_774857019211516_3250373144789554679_oSince it’s Recordium’s first anniversary, we decided to make it Free for a very limited time (It’s still free as I’m writing this post). Hurry!

From the first hours of this promotion, the app rocked the store! We hit number 1 (in productivity and business categories) in some countries including Australia, Germany, and more! Yeah this is pretty impressive!
The following is the latest top charts from the App Store:
14 - 1
I think it’s a good time to say that I am proud of working with such talented people. The team at Pichak spent months to develop something lovely for the users.
Lots of new cool stuff are about to happen in Recordium including lots of new features and improvements. By the time, we’ve released Recordium Mini, a compact version of Recordium Pro for those users who just want to highlight their voices. Lots of good news are coming soon. Stay tuned 😉

Why don’t you enable comments!?

One of the best tasks I’ve done last week was to revise my Feedly feeds. I removed some feeds which hadn’t been upgraded recently and also added some new feeds. I also came across some Persian bloggers and added their feeds as well.

Yesterday I was reading a post by a blogger about technical matters. I thought I can complete the blogger’s idea by adding a comment. When I wanted to do so, I realized that the comments are closed! When checked other post by that person, I found out that there’s no comment capabilities at all! Why?

One of the biggest purpose of blogging is to share your experience with others. No one in the universe is complete enough; consequently, there might be other thought that can complete your ideas which are posted on your blog. Some of the times, I find my solutions in the comments rather than the post itself.

I know there might be some S P A M M E R s out there which can bother you; but, lot of blog extensions and plugins are available today to reduce them. Comments could also be moderated to avoid inappropriate contexts. There are also other options which can be used like Disqus. It’s a very powerful comment system which can be installed very easily on your blog. It manages all comments on your blog. I also used Disqus on my blog too.

If your blog comments are disabled, please re-enable it to improve your knowledge.

Thank you 🙂

How to create installation DMG files in OS X

One of the coolest features of Mac OS in comparison with Windows is the simplicity of apps’ installation. In Windows, in most cases, there should be an installation package; otherwise, the app won’t run correctly. On the contrary, Mac apps installations are much simpler. All you need to do is to copy the app bundle to the Applications folder; so, no installation is needed. The installation process of Skype for Mac is a very good example. To install Skype you just need to drag the app icon into the Applications folder. by doing this, you’re copying the Skype app bundle to your Applications folder. The following is the Skype installation page for OS X:


Now how can you create such installation page for your own app?

First of all, look at the picture above. The installation page contains three major sections:

  • The First is the application bundle (in this case,
  • The second is the OS X Applications folder.
  • The third one is the background image of the installation page.

These three things are the requirements to create a DMG installation file. However, you can ignore the background image and let it be just a solid white color background, it’s much better to have a custom background color or image for your installation page. It make your installer more friendly and of course more beautiful. In addition, there is one more requirement (which is obvious of course): You will need a Mac machine to build DMG installation files. As far as I know, you cannot create DMG installation files in Windows.

Getting Started

After all of three requirements I’ve mentioned above were present, you can get started. I decide to break this tutorial into steps so it’s much easier to understand:

The very first thing to do is to create an empty DMG file so we can put our custom files in it. To do so, OS X has a built-in tool named Disk Utility. You can simply search for it in spotlight search box (On the top right of your screen).


In the Disk Utility home page click New Image button on the top of screen. When New Image button is clicked, a window will be appeared like the following:


There are some settings in the New Image window which need your consideration. The first field is the path of your DMG file that is going to be created. The second field is name. It is recommended to set this field as the name of your application because users will see this name when they mount your DMG file on their machine. The third field is size of disk image. Unfortunately, disk images’ file sizes could not be dynamically allocated so you need to pick a size which is right for your application’s size. It’s recommended to choose a size which is a little larger than your application bundle (The minimum size of disk image is 21MB in OS X). The forth field is image format. This field’s value is set to Mac OS extended by default and there’s no need to change it; so, leave it as it is. Encryption and Partitions fields are fifth and sixth fields in the New Image window which should be left as the default value. We don’t need any encryption or partitioning for now. The last field, Image Format, is sightly important here. You have to set this field’s value to read/write disk image. You won’t be able to create the installation DMG if you select anything else! After setting all fields, click “Create” to create the disk image.

By clicking “Create” your disk image will be created and will be automatically mounted. Close Disk Utility, go to Desktop and double-click on the mounted image to see its content. You can see the disk image is empty as you expected. In the next section we need to fill it by adding our custom files. The reason we’re able to add files to our disk image is because we set the image format field to “read/write disk image”.

It’s time to add our custom-designed background image to our installation (If you don’t want to add an image to your installation page, you can skip this section).
You can simply drag your custom background image to the mounted disk. As you can see the file has been copied to the disk image but has not set as disk image background. To do so, right click on the mounted image on your mac desktop and select Show View Options.

myapp_show_view_optionsThere are two things that need to be taken care of in the Show View Options page. The first one is Icon Size and the second is Background.

Icon Size indicates the size of our two main icons in the installer page (Our two icons are your app bundle icon and the Applications icon). Icon size is completely up to you. In the Skype example I’ve mentioned earlier, the icon size is set to the maximum which is 128*128 pixels. I myself prefer to use the maximum as well; because, it makes it easier for users to do the drag-drop action.

After setting the icon size, it’s now time to set the background image. Just select picture item from background radio button group and then DRAG the image you’ve just copied into the disk image (not from other paths of your hard drive) to the “Drag image here” section. As soon as you drop the image, the background will be set. There’s no Save button. All changes will be saved automatically; so, you can close Show View Options window. You can also resize the disk image window by its corners (as same as what you do when want to resize other windows in OS X) to fit your window size with the background image.

The interesting part is that all of your actions will be kept and the next time you open your disk image, background image, icon size and window size is saved.


As you may have noticed, The image file is in the middle of disk image window. We need to make it hidden so users can’t see it. There are plenty of ways to make a file hidden but one of the coolest ways is to add a “.” to the first of file name. In Unix systems like Mac, files which are started by a “.” are hidden by default. You can’t change the file name in the finder. You need to rename the file in terminal. So open a terminal window and do the following:


As you can see the file is now hidden!
The next step is to copy our app bundle. To do it just copy the app bundle to your disk image. You can also change the location of app bundle to any place of disk image we want. After the bundle has been copied, We need to make an Application icon so use can drag the app to it. To do so, go to you Macintosh HD, click on Applications, hold Command and Option key, and drag it to the disk image window. By holding Command+Option it will make an alias of that folder. Note that we’re not copying the Applications folder, we’re just making an alias from it. Place the two icons near each other so it’s easier for users to install the app.

We’re almost done. Your installation DMG file is ready; but, there is something. By publishing this DMG file, all users can change its background image, icon size, window size, and etc. In fact, they can do whatever you can! To prevent this, we need to make this disk image read-only.
Eject the disk image by right-clicking on disk image icon and selecting “Eject”. Re-open the Disk Utility tool again. On the left side of Disk Utility home pas select the DMG file we’ve created, then, select Convert. The convert window will show up. select a unique name for it and from Image Format select read-only. Click save to create a new disk image from your selected one. The new DMG file we’ve just created is read-only can be safely published and others cannot make changes to it.

If you have any question, don’t hesitate a moment; just ask it on the comments down below 🙂
Hope it helps.

Run a bash command in Objective-C

During the last month, I’ve been very busy developing apps for iOS and OS X. OS X development was very enjoyable and interesting for me since it was my first time developing Mac applications. During this development, I’ve learned lots of things. some of them were very basic concepts while some were very complicated. The app I was developing needed to execute bash commands to access sensitive parts of OS X, so I had to have a function for calling these bash commands and in this post I’m going to share my experience with you 🙂

First of all you need to create a NSTask object.

Using the NSTask class, your program can run another program as a subprocess and can monitor that program’s execution. An NSTask object creates a separate executable entity; it differs from NSThread in that it does not share memory space with the process that creates it.

NSTask *task = [[NSTask alloc] init];

Then you have to set the file or path that has to be executed using setLaunchPath: method. To make my code clean, I prefer to create a new variable called path and assign the process’ launch path to it. In this case I’m going to launch the ping command:

NSString *path = @"ping";
[task setLaunchPath: path];

As you may know the bash’s ping command requires an argument which is the destination’s IP address or host name that want to be pinged. So we need to pass an argument to our NSTask object. NSTask has a setArguments: method which accepts an array of objects. So we have to create an NSArray first and then pass the array to the setArguments: method:

NSString *pingParam = @"";
NSArray *args = [NSArray arrayWithObjects: pingParam, nil];
[task setArguments: args];

You can now run the task using [task launch]; method; but, if the command you’re executing had a return value, you won’t get it. Thus, you need to create an output. NSPipe is an standard output you can use to get the results. You have to tell the task you’ve created what kind of outputs you want to use.

NSPipe objects provide an object-oriented interface for accessing pipes. An NSPipe object represents both ends of a pipe and enables communication through the pipe. A pipe is a one-way communications channel between related processes; one process writes data, while the other process reads that data. The data that passes through the pipe is buffered; the size of the buffer is determined by the underlying operating system. NSPipe is an abstract class, the public interface of a class cluster.

NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput: pipe]; //Telling the task object what output to use.

Now the return value of our task will be passed to the pipe object. Now we need to get this value. To do so, we need to make use of NSFileHandle object.

The NSFileHandle class is an object-oriented wrapper for a file descriptor. You use file handle objects to access data associated with files, sockets, pipes, and devices. For files, you can read, write, and seek within the file. For sockets, pipes, and devices, you can use a file handle object to monitor the device and process data asynchronously.

NSFileHandle *file = [pipe fileHandleForReading];

Now we can safely run [task launch] method and launch the task. After launching, we need to get the value which is returned. When [task launch] is called, it stops the main thread until the results are returned. Although, you can make the task launch asynchronous if you want but in this example the application waits until bash results are returned.
After the process has been successfully launched, it puts the results in the NSFileHandle we’ve just created. By default, results are in NSData format because it could be any type of data. In this case, the result of a ping command is nothing but a NSString, as a result, we need to convert the NSData to NSString:

NSData *result = [file readDataToEndOfFile];
NSString *resultString = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
// Your result is ready. We want to just print it by using NSLog command:
NSLog(@"The result is: %@", resultString];

Done! Your bash command is executed and the results are returned.

Hope it helps.