Monthly Archives: January 2014
In this post, I will discuss about the Java Native Interface(JNI) and Java Virtual Machine(JVM) on Mac OSX.
JNI stands for ‘Java Native Interface’. It will act as an interface between java and other languages. JNI allow a code written written in languages like C, C++, Objective-C etc to use java libraries and from java code to use other language code.It means you can call java methods from other languages using JNI and vice versa. Java native methods are flagged by the keyword ‘native’.
- Use the existing library,
- Speed of execution,
- Invoke API functions from product that is developed in C or C++ from a java client and vice versa.
- Run time errors debugging is difficult in native code.An applet can’t call a native methods. You can’t say ‘write once run anywhere’.
Introduction to JVM
JVM stands for ‘Java Virtual Machine’. Java Virtual Machine or JVM is a platform independent execution environment that converts Java byte-code into machine code(binary). JVM function is to load the appropriate class files for executing a java program, and then to execute it. Read the rest of this entry
Suppose, I want to create a application which will monitor the typing and say if “macdevelopers” is typed anywhere be it in TextEdit or Mail etc. the application will perform a operation for example automatically opening the website in a browser.
The text value from any System wide Application can be accessed using the Accessibility API. In this article I will discuss about accessing the text value from any application like Text Edit or other applications if its current focused element is some text field or text view in it. Thus using this you can implement the functionality to access the active application’s text field value. Read the rest of this entry
Undo/Redo functionality in a Cocoa application – NSUndoManager
This article will give you an overview of adding undo and redo functionality to a cocoa application by an example that undo/redo addition and deletion of rows in a TableView.
Lets start with How Undo Manager works?
As per Apple’s Reference Guide “You register an undo operation by specifying the object that’s changing (or the owner of that object), along with a method to invoke to revert its state, and the arguments for that method. When performing undo an
NSUndoManager saves the operations reverted so that you can redo the undos.” Read the rest of this entry
What are Protocol Buffers? Protocol Buffers are a way of encoding structured data. Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data like XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. You can even update your data structure without breaking deployed programs that are compiled against the “old” format.
How to use Protocol Buffers with Objective C?
First let me make it clear that we are not discussing about finding if a application is running or not, which can be found out very easily by using [[NSWorkspace sharedWorkspace] runningApplications].
We are going to discuss how if we can, get the information about a file that whether it is open or not through a Cocoa Application.
Before going further down in the topic let us consider following scenarios to understand the need of the discussion.
1. A Cocoa application might be concerned with performance enhancement and for that it might need to find and list out the opened files.
2. A application might need to find the port associated with a daemon.
3. A application might need to constantly monitor a document or documents in a particular directory and when user close that document after editing, it has to perform certain tasks.
Circular progress indicator We all are familiar with native progress bar but a circular progress bar might be required in a project. In circular progress bar, progress of process will be shown by a bar filling in clockwise or anti-clockwise direction. Here I am providing the code to create a circular progress bar as shown in the image below: Read the rest of this entry
Let us first see how to view system information on Mac manually
To find the Mac OS version and memory information, go to the Apple menu and choose “About This Mac”.
The About This Mac window should look similar to this: Read the rest of this entry