GranitW
Lockergnome
Home

Archive for Operating Systems

Mac OS X 10.5.3; first beta released

Apple, on thursday, started seeding Mac OS X 10.5.3 to developers. So far, this update has about 75 bug fixes including critical memory leak with Core Animation. It seems the third update to Leopard will be coming in either April or May.

iPhone: To Be The Dominant Mobile Device. Goodbye BlackBerry

Yesturday, it seems that Apple’s servers were bogging down. Now I don’t just mean they were running slow, I mean many people couldn’t even access the developers site. Why is this? Because there were over one million developers trying to download the 2GB, finally released, iPhone SDK. Yes, it appears, after what Apple demoed at yesterday’s conference, that Apple wasn’t joking around when it bluntly said the iPhone is years ahead of its competition.

Personally, I’ll be one to say, I’ve never seen a full desktop game running on a smart phone. Most have low resolution graphics and very horrible sound. Apple, EA, and even Sega show-case the power of the iPhone with three very good looking games like Spore and Super Monkey Ball.

Just in five minutes on the Internet, I spotted about six articles about the iPhone and its SDK. All of these takes upon it were positive and very similar. They all saw the iPhone as a next generation phone, that could in fact make a decade long monopoly for Apple as the dominate mobile device. Here’re a few quotes and snippets:

“It’s clear we’re not the only ones interested in the software development kit (SDK) — after a few hours of trying, we still haven’t had any luck downloading it” - alleyinsider

“There should be significant concern in the RIM camp… By summer there could be hundreds, if not thousands, of applications ready for the iPhone” - Computer World

“The iPhone/iPod touch games will make the iPhone analogous to the Wii, in that it opens up new concepts in game UI design”

“[Apple’s iPhone, iPod touch developer] tools look awesome — far better and more advanced than what most Mac developers were expecting”

“Then Apple kicked things up a notch with the SDK details… But the real surprise was Apple’s efforts to market and develop an ecosystem for third-party iPhone development [including] Kleiner Perkins’ [launch of the] $100 million iFund to fund iPhone developer companies” - Notes From Anywhere

“By the time Apple officially releases the OS X 2.0 update in June, there will be no doubt that the iPhone will have turned both the personal computing and mobile communications industries on their head in just one year” - CNET

Apple’s Pippin, the So-Called Gaming Platform (With Video)

I’ve noticed recently that people have been giving Apple’s Pippin attention, saying Apple did once have a gaming console. The truth is Apple has never had a game console, unless you count the Apple ][ with the old DOS games. The Pippin physically doesn’t truly exist. It doesn’t have a form of solidity because it’s an SDK and an operating system, not a computer or console. Now what people have seen, if they’ve seen a console-like device, is something called World. World was a platform made by Bandai, the only Licensee that Apple could get for the Pippin platform. I do need to add, however, that in America people sometimes refer to World as Pippin instead of just the operating system or SDK.

World is not a gaming console. It was based on Apple’s idea that the computer world would end up in the living room. In other words, it was a Windows Media Center before there was a Windows Media Center. It could, of course, play games, but it could also play much more — like movies and music. It also had Netscape to access the Internet.

Here’s a video I have from Computer Chronicles (1995):

Market Share Analyzing is a Pseudoscience Just as Bad as Astrology

Now before I begin, just to clarify, because I see this mistake many times. Astrology and Astronomy are completely different subjects, Astrology is a false science that uses patterns in the sky to tell your future.

For a long time now, I’ve been telling people that the market share graphs and surveys are false; it seems very few believed me. The reason I said that had to do with the fact of how market share information was gathered. You see, a company like Net Applications has a snippet of code that is put into hundreds of Web sites. The code can tell what computer the visitors are on, and then send that information back to Net Applications.

The bad thing about these types of invisible surveys has to do with the Web sites themselves. From what I’ve learned most of Net Application’s Web sites are on e-commerce sites. At this time there are still many e-commerce sites devoted to Internet Explorer and/or Microsoft. One of which was Wal-mart’s online music store (which is gone now). You see Net Applications doesn’t list the Web sites its code is on, so you don’t know if any Web site is biased toward an OS or works better on a specific browser, or tends to get more of a specific OS because of what they sell.

Well now today I’ve found proof of how unreliable this method is. I found another Web site, which I trust a lot more than New Applications, called w3schools.com (W3 is the consortium that creates the open Internet standards).

Here’s a comparison:

Browser
W3
Net App
Internet Explorer
53.2%
75.25%
Firefox
37.2%
16.65%
Safari
1.9%
5.33%
Opera
1.4%
0.62%

So as you can see, there are some big differences, and actually W3 and Net Applications can’t seem to agree on any of the browsers. Firefox for instance seems to have more than twice the market share on W3’s side compared to Net Application’s.

This statement above can reflect on another similar market share Net Application does — the one that everyone seems to base their facts upon: The Operating System Marketshare. This has the same results as above. W3 actually says that Linux has a market share that is over five times the amount Net Applications says (3.6 > 0.67). So what does this say about Vista? Well, let’s look at Apple’s share. Net Applications says there are roughly 8% of computer users on Macs. Steve Jobs commented a while back that there are 23 million Mac OS X users. Estimating, I believe it is close to 26 million today. So what does that say? In total it appears that there are only about 320 computer users in the entire world. 320! that’s impossible — that’s less than 100 million over the population of the United States, so what about the rest of the world? I remember Microsoft claiming that there are close to a billion computer users out there, but then where did they go? I then did the same thing with W3’s information and got double the users at around 650 million. So who’s right? Are they both wrong? Who knows?

So once again, do listen about who has a larger market share, it’s all just a pseudoscience.

HowTo: Mac OS X’s Open Application Architecture Basics, Modify Safari

Mac OS X applications seem very solid and functional, but in fact an Application in OS X is just a basic folder with the “.app” extension on it. This type of file structure is called a bundle and it’s what Apple has been using not only for Application architecture, but for documents as well. Native iWork Documents, for instance, are folders that contain a compressed gz file, extra resources, and an informational property list.

So what does this mean? It simply means you can get into the contents of an Application or document very easily, just like opening a folder.

Below is a video showing how to open the contents of Safari.app and changing the Activity Window, and making the Activity Window the first item to open. You do need Apple’s Xcode tools to be installed to do any modify of Applications with ease(otherwise your going to have to use a text editor and edit the xml files by hand). This of course makes it so the MainMenu item wont open, so no menu will appear at the top of the screen. I did this by openning up the ActivityViewer.nib file. A NIB(NeXTSTEP interface Builder) file is an interface file, modern files now are called XIB(Xcode Interface Builder). I also modify Safari through a property list. A property list is very similar to a Hex code based system that holds certain properties to a file. The great thing about a property list though is that it is completely human readable. Even a non-programmer can understand it.

Mac OS X: 10.5.2, the Ups and Downs

Mac OS X 10.5.2, so far has been a great update.  There are some problems I’ve noticed and some features I like here’s the break down:

Ups:

-Everything runs seems to run faster

-The graphics have really jumped up in Performance.  A game called Civilization IV which stopped working with Leopard 10.5, now works again and actually works even better(no audio or graphic glitches).  Even Bwana did a post about the new graphics driver reporting that some one got 20+ FPS WoW with this update(went from 30FPS to 50FPS).

-I like the new option in stacks to view in list mod.

-Many bugs I had seem to of faded, OS X now feels very stable

-Spotlight seems more stable, it’s not indexing constantly anymore

-It also seems like more Carbon apps are running better

Downs:

-I was hoping Appication stacks would return(they were in the betas of Leopard back before October) .

-You still need a 3rd party app to turn the 3D dock into a 2D one for the bottom of the screen

-A graphics glitch in the Finder, when I go to directories, every now and again the Window will start to fade out distort.

-I’ve been having issues with compatibility between 10.5.1 and 10.5.2,  I have another startup disk on my computer with Leopard.  An application I made in 10.5.2 doesn’t seem to work in 10.5.1 for some reason.  It appears to be a Webkit issue.

Final thoughts:

So in All I’d give Mac OS X 10.5.2 about a 3/5.  It’s  great update, but many of the new changes are bug fixes and optimization more than anything.  I’ve also noticed some very major graphic issues.

HowTo: Mac OS X Application Development Guide, Part 3

This is a series of guides about OS X Programming.

Who Should Read this:
This is a continuation of a guide that teaches people how to program in OS X. You can find the previous article here.

This tutorial is written for both beginners and experienced programmers alike. Much of it can probably be skipped by skilled developers. You should at least have good experience with Mac OS X. This part does include using OS X, finally.

For “already” programmers, this guide focuses on programmers that develop in C, C++, BASIC, Java, and other similar languages.

Organization:
I have split up the categories and concepts into grouped paragraphs to make it easier to skip or navigate through the article. An example of this is right below with the title of the group: “Get and Install Xcode“, in bold. I have also highlighted parts of the text like this: “example“, for beginner programmers that other developers can pass over. There is also something called “In Depth“, which explains more in detail of something. A new item in this guide are videos that can help you through the tutorial.

Much of this guide is overly in depth, and you can skip just about any part if you don’t want or need to learn anymore of a specific subject.

Get and Install Xcode:

Apple’s Xcode is the application, as well as the development suit, used to create OS X applications. You can get it from developer.apple.com for free, you do need an ADC account to access the downloads. The online ADC accounts are free. Be warned for people with low speed internet, Xcode is over a gigabyte, so it might take a while to download. If you have a copy of OS X Leopard, Xcode 3.0 is already on that disc ready for you to install it.

In Depth:
You do need to get Xcode 3.0, since this is the one I’ll be using for the tutorials. Version 3 is for Leopard and Tiger. You can still try to use Xcode 2 with this, but version 3 is dramatic different, some main applications have even been given a whole new interface. Also Version 3 brings in Objective-C 2.0, adding more features like properties.

When installing Xcode you can customize what you want installed. One that some might not want is the UNIX Environment tools. This just installs a duplicate of Xcode’s UNIX tools, like it’s compiler, into a different location so that the UNIX kernel of OS X can find it. This is useful only when you plan to install open sourced/ un-compiled software through the UNIX terminal.

Another item to look at is “Mac OS X 10.3.9 SDK”. Xcode 3.0 installs the 10.4 and 10.5 SDKs automatically, but leaves the 10.3 SDK as an optional install. Almost every major version of OS X are different from one another, so different that each version is considered it’s own platform. In Cocoa, multi-platform applications refer to programs that can work on multiple version of OS X.

Xcode:
After installing Xcode, go to your startup volume(Macintosh HD). In here you’ll find a folder named Developer. This is where Xcode has installed into, open this folder. Now you should see even more folders like: Applications, Documentation, Examples, Extras, headers, Library, etc… Open up the Applications folder in here. This is where all you developer tools and applications are held.

Two applications you should know about right now are Xcode and Interface Builder. Xcode is what developers use to create applications for OS X. There are a few 3rd party IDEs like REALBasic and Dimension. Before the intel transition, there was also Code Warrior for OS X, but at this point it has been discontinued.
Now, you can make Applications with 3rd party IDEs, but the problem is that they wont be as native or bug free(as possible) as an application made with Xcode. Xcode has been designed to build many different application environments and languages like the ones below:

Cocoa: OS X’s main Native environment. The languages you can use for it are Objective-C, *Java, Python, Ruby, Objective-C++, and Applescript.

*Note from Apple: Cocoa-Java is a learning environment for developers familiar with the Java language. It is not recommended for production work. The Cocoa-Java API is no longer maintained in parallel with the Objective-C API as the latter evolves.

Carbon: OS X’s secondary Native environment. The main languages used in this are C and C++. Originally carbon was created for people to easily port classic applications from MacOS 7,8,9 to Mac OS X. Today carbon is used to easily port C++ applications from windows and other platforms to the Mac platform. Examples of carbon applications are Adobe’s creative suite. The problem with carbon applications, especially in more modern version of the Mac OS like Mac OS X 10.5(Leopard), are bugs. Although not a bug, there are also bad GUI effects where the controls aren’t being composited correctly on the windows. One great feature of using Carbon is the ability to use some Cocoa APIs and features.

Java: This is a Nonnative environment using a virtual machine to run the application. It uses it’s own language, Java, but has some features and API of Cocoa rewritten for Java. This is normally only good if you plan to make multi-platform programs.

UNIX/BSD: this is *Darwin Native, with the ability to run on top of OS X with a GUI system like X11. Darwin can understand almost any language as long as you can find the right gcc compiler for the language. Here’s the languages Apple’s gcc compiler understands: C, C++, Python, Ruby, and others; You might need to download extra libraries for more support, like GNOME or KDE which don’t come shipped with OS X.

*Darwin is the operating system(kernel) underneath OS X and is based off of BSD, FreeBSD, netBSD, Mach, and a few others. Mac OS X itself is primarily a library of Frameworks and APIs. The user layer of OS X, is just made up of applications like Finder.app, Dock.app, and Spotlight.app. These applications are just like the ones you can make in Xcode, and many were made in Xcode. You can find these system applications in: Macintosh HD -> System ->Library -> CoreServices.

Now launch Xcode. The first thing that pops up is a menu with a few settings. Just use the default settings for now. Another window, is a splash screen with information about using Xcode, you can look at the information this window provides or just close it.

Building a Basic Browser:
In Xcode, go to the menu bar -> File -> New Project. This will bring up a wizard that will guide you through. The first thing to choose is the type of application and its environment you want. As you can see there is quite a list, but remember these are just the preset projects, not the limit it gives you.

Now we plan to make a native cocoa app, so scroll down the list till you find one called Cocoa Application. Select this, and then click the ok button. Next you need to give your project a name, and tell Xcode where it will be created. Name it something like Basic Browser.

Once your done, just click Next. Now your new project window will popup. On the left side of this window, a list of assets, from source files to frameworks, to the final Targets are located. Now go down the bottom of this list of assets to a Group called Nib Files. Open this by hitting the triangle and then double click the MainMenu.nib file. This will then open MainMenu.nib in Interface Builder.

Making the Interface:
Interface builder is the main place you’ll go to edit and create graphical interfaces for your applications. You can also develop interfaces in code if you’d want.

The first thing you should see is a window with the title: “MainMenu.nib”. This is where all the assets go for this particular interface. The items in here are:

File’s Owner: The Object that owns and controls the nib file

Application: The Object that represents the entire program

First Responder: This is part of something called the responder chain, which will be explained more in the next part of the guide.

Window (Window): The main window that will launch when you run the program. This is always created when you build a standard Cocoa application, but most programs don’t use this method and instead normally contain each window in it’s own nib file and not the main one.

MainMenu: This is the main menu bar of the application.

Now there might be another window open, if not go to the menu bar -> view.
This window is the library of pre-made objects. Many of these objects are called views, and are sub-classes of NSView. An NSView object is what is used to create visual interfaces like a button, or a text field.

Now go to the projects Assets window and open up the Window. You’ll see it’s pretty blank. Now go to the Library of Assets and go down main categories to something called Webkit. Go into this and you probably find one object called WebView. Drag this out onto the window, then resize it to fit the entire window.

Now go back to the library and go into the Cocoa category, now look for a group called NSToolbar. Drag out the NSToolbar object to the toolbar on the window. This will create a new toolbar for you. Now double click on it and it’ll open up, now delete all the pre-installed toolbar items that come with it.

Now go back to the library again and go into the Cocoa category and look for a view called an NSButton. Drag over 6 of these buttons to the toolbar. Now find a NSTextfield and drag it over. Now resize the buttons and window to your liking. then rename the buttons to:

“Back”
“Forward”
“Font +”
“Font -”
“Stop”
“Reload”

Now drag these buttons and the text field out onto the Window’s toolbar. Now close the toolbar’s customization sheet window by clicking ok. Then go up to the menu bar -> View -> Show Inspector or do the short cut: shift-command-I.

This is the window you use to edit attributes about an object. Now make sure the Toolbar is selected and go into over to the Inspector Window. Check to see if the first tab is open and change it so only the views are shown, without the text underneath them in the toolbar.

Here’s a video of the above steps(Click on Image):

Now select the WebView object and go to the size tab in the Inspector window. In the Autosizing part, click on the faded arrows which appear in a black outlined square. This makes the WebView stretch as the window stretches.

Connecting Actions:
An action is one of the ways that objects interact with each other through user input. Every time you click a button your sending an action for instance.

Many objects in Interface builder come with pre-made actions,and we’re going to take advantage of this. Double click the Toolbar in the Window object to open up the customize sheet window. Now right click or control-left click the button with the titles, Back. Drag the cursor to the WebView. As you do this, you’ll notice a bluish line, when the WebView highlights(when you’re over it with the cursor, let go of the mouse button. A black HUD window should appear. This window lists actions that the WebView contains. Find the goBack: action and click it. Now do the same thing with the rest of the objects in the toolbar as shown below:

Back = goBack:
Forward = goForward:
Reload = reload:
Stop = stopLoading:
Text+ = makeTextLarger:
Text- = makeTextSmaller:
The Text field = takeStringURLFrom:

Now simulate the interface by going to the menu bar -> File -> Simulate Interface. The first thing to happen is the browser Window opening. in the textbox type in a url. Remember this is a strict system that needs the user to type in the full address, so type in an address like this: “http://www.google.com/”. After, hit the return key. That’s it with the interface it works. Now go back to Xcode and at the top of the Project Window, click Build and Go.

What did you notice? Did you realize it didn’t work, is your app just bouncing infinitely in the dock? . Yep, even in Cocoa, it’s not that easy to make something as complex as a browser that easily. Actually there is one last step needed. You need to link the webkit framework to your project.

So now, go back to Xcode and go up to the menu bar -> Run -> Stop. This will terminate your application. In the project Window, go over to the left side and scroll to the group of assets called Frameworks. Open this, then right click or control-left click the group called Linked Frameworks. In the contextual menu go to Add -> Existing Frameworks… Now it will pop up a modal window with the frameworks folder. Go down to the bottom, and you’ll find Webkit, at about the second last item. Now add it. Xcode will prompt you with a sheet window, but simple hit Add again.

Now once again click Build and Go. It should work, and now you have a fully functional, yet basic web browser.

There’s yet another video:

Extra Information:
With your new program running in the Dock. Click it’s icon in the Dock, while holding down the command key. This will open up its parent folder in the finder, showing you where it’s located. Now right click the Application in this new Finder window, then click Show Contents. A new window will pop up, go into the folder Contents, then Resources, and again in English.lproj. You’ll find the interface you made. OS X applications rarely compile the nib files. This means that you can click on this nib and edit your interface with Interface Builder, even though your app is already compiled.

HowTo: Mac OS X Application Development Guide, Part 2

This is a series of guides about OS X Programming.

Who Should Read this:
This is a continuation of a guide that teaches people how to program in OS X. You can find the previous article here.

This tutorial is written for both beginners and experienced programmers alike. Much of it can probably be skipped by skilled developers. You should at least have good experience with Mac OS X. This part does not include using OS X yet, and more focuses on the background of OS X programming and the Objective-C language.

For “already” programmers, this guide focuses on programmers that develop in C, C++, BASIC, Java, and other similar languages.

Organization:
I have split up the categories and concepts into grouped paragraphs to make it easier to skip or navigate through the article. An example of this is right below with the title of the group: “Basics of C“, in bold. I have also highlighted parts of the text like this: “example“, for beginner programmers that other developers can pass over. There is also something called “In Depth“, which explains more in detail of something.

Basics of C:
C is the most widely used language in the computer world. Almost every language whether C++, Objective-C, or Java, your using the concepts and ideas created by C.

In Depth:
In the 60s, AT&T Bell labs was developing an operating system called Unics, they created a language to write it in called B. In the late 60s to early 70s, the programmers wanted to make the OS more portable, B was to integrated with the hardware to allow this. They need to develope a new Languages, this is what started the development of C. A few years later, AT&T Bell labs finished their OS in C renaming it UNIX. C is a very portable system that can rest on almost any hardware setup making it very popular. C was also very easy to use compared to other languages.

To start off with with basics of C, you need to understand the “#include” keyword. This is a needed asset which imports and connects outside resources to your code. The most imported resources would be from the standard library for the language along with other resources to your code. In Objective-C, you’ll normally be adding something called Cocoa.h to each document in your project.

If you’ve used another language like BASIC, this concept might be new. In BASIC, the library/compiler is normally proprietary and built into the IDE(Integrated Development Environment) application. In C and languages based off of it, the compiler is noramlly not a part of the IDE, this means it needs more information on what to do and what code to use. Also, compilers like this are more open and extensible. This can help expand developers’ applications by giving them the ability to use 3rd party frameworks and systems. This is one of the big reason for the include keyword. Besides making the applications more feature rich by allowing outside sources to connect to it, it can also make your code more organized and make your programs smaller.

In an environment like Realbasic, for instance, a application is given a dylib(Dynamic Library). This dylib contains all the functions and resources built into Realbasic, not just the ones you’ve used. This can add up to large file sizes. In C and other languages, the include keyword is not just needed to import the standard set of libraries, but to import only the ones you want, making your applications small.
Another great feature about the #include, is that it allows you to split up your code into multiple files. This allows more people to work on the same project, and it makes it easier to go over a specific asset. Here’s an example line for including a source file, which normally is a header file.

#include <stdio.h>

The first part is “#include”, which tells the preprocessor(a system before the compiler) to include a source file. The next part is “<stdio.h>”. The “<” and “>” tags mean that you want to get the source file from a standard system folder, normally one containing files from the standard set of the Language. The “stdio.h” is the source file your looking for. Now this code is not for the actual compiler. This line is for something called the preprocessor. All keywords with the “#” in front of them are for the preprocessor, which gets the code polished up and ready for the compiler.

Lastly with the #include keyword, to access normal source files you’ve made, you should use quotes instead of tags like this:

#include “foo.h”

This means that it will look in the same folder as your code, for the file foo.h.

The next part to know about C are the variables. Variables are an incredibly valuable resource in programming. a variable like explained in the last part is a space that holds data. Here is an example of declaring or making a C variable, with a BASIC version of the code underneath:

int foo;
Dim foo As Integer

alternative:

int foo = 100;
dim foo As Integer = 100

alternative:

int foo, foo2;
dim foo, foo2 As integer

The next important part to learn about before getting into Objective-C, is the conditional statements. A conditional really helps make a program non-linear and more feature rich. Just about every program out in the modern world uses many of these conditional statements. Here’s an english readable version of one:

If a person presses the computer’s power button, then the computer will turn on.

Now above, a computer won’t understand what that means. We have to translate it into a more simplistic form like this:

if(person.presses == computer.powerButtonPressed) {
computer.turnOn;
}

Above, I wrote out the same sentence in C. At this point ignore the parentheses and curly brackets. The first part is “if” which is a keyword that starts the conditional statement. The next part is “person.presses”. I made the person into an object, and presses into a method. The method returns a boolean(true or false) value. Next I added a “==” which means I want to see if the right side of the statement equals the left. After that, I add “computer.powerButtonPressed”, in which computer is an object and powerButtonPressed is a method returning a boolean value. “Computer.turnOn” is the results of the conditional statement.

For beginners you might want to look over the last paragraph a few times before continuing.

Now about those brackets and parentheses. In a language like C, these are normally used as containers. These containers hold code with in them, away from the global code. A real world example would be: in a house, a refrigerator is a container that holds food. Now in the conditional statement above, the parentheses are used as a container that hold the statement. The curly brackets are used as a container that holds the results.

In C, “=” and “==” are to different operators. “=” means you want a variable or another asset on the left side to contain the value of the asset on the right side. The “==” means you want to know if the value on the left equals the value on the right:

int var1;
var1 = 5;
this makes var1 have the value 5.

if(var1 == 5){
do.this;
}
this checks to see if var1 does equal 5.

Objects and Classes:
The Language C, is not an object oriented language. It is a procedure language, which means it uses steps to reach it’s desired output or state. In Object oriented languages like Objective-C you use objects and methods to create a network or structure that forms your application. Another concept you need to learn about are classes. When you create your own custom object, your making what is known as a class. A class holds the information needed to create the objects and is more like the factory than the product(in a sense).

A class tells the compiler what the object is and what methods and other assets it has. When you build a class in some languages it looks like this:

function Class1{
this.method1 = function{alert(“hello world”);};
this.var1;
}

Above is an example of a class from Javascript. In many languages there is something called a function. A function separates code like a container from the global code, it’s useful because the container can be called from anywhere. This can save you from writing down the same code more than once since it’s already in the function. Many languages were created before or away from the idea of the object oriented concept. To adapt, many languages just expanded on the functions to create class interfaces. To make the above function class into an actually object also called an instance of the class, you do this:

var object1 = new Class1;

In Objective-C, normally a class takes up two files, the header file and what is called the implementation file. I’ll get into those later. here’s how to create an Objective-C object:

NSImage * image1 = [[NSImage alloc] init];

Understand Some Objective-C Concepts:
In Depth:
Objective-C is based off of C, but more specifically it’s an extension to Ansi C. “Ansi”, just means that the C code used is the standard set by the American National Standards Institute(ANSI). To be even more specific, Objective-C is based off of a language created at Xerox PARC known as Smalltalk.

Smalltalk, released in 1980, was the first language called object oriented. Smalltalk and Objective-C are what is considered pure object oriented. Unlike C++ or Java, in a pure OOP primitive values(integers,characters,etc) are the same as object values. To add to this, in a pure OOP, primitives like integers are objects themselves. Like for instance, in C++ you’d use a variable like int, in Objective-C you’d use NSInteger. NSInteger isn’t just a variable, it’s an object.

In C, like above, you have the include keyword, written as “#include”. This resource happens to be in Objective-C as well, since Objective-C is on top of C. Now to tell you the truth, you should never use #include in your Objective-C programming. Apple, replaced this concept with something called #import. This has the same properties as include and works almost the same way. The only difference with the import keyword compared to the include, is that it tells the preprocessor to check to see if the code it’s trying to import has already been imported. If you use “#include”, it wont care if it already imported the code, it’ll do it again making your apps bigger than they need to be by having 2 or more of the same exact thing. here’s an Example:

#include <Cocoa/Cocoa.h>

#import <Cocoa/Cocoa.h>

If you plan to use ObjC to make applications in OS X your going to have more than one source file in your program. Each one of these files connects to the Cocoa.h header file. If you use #include you will be compiling Cocoa.h in your application multiple times. This can lead to a large file size, and even a long compiling time.

Objective-C or ObjC uses a different means of building objects and accessing methods and variables than most languages including C. You can however use C functions and methods with ObjC with no problem, like this:

NSLog(@”this is an Objective-C String”);

NSLog although looks like an ObjC function of some sort, is actually C. The part in the parentheses is ObjC. The “@” tells the compiler that this happens to be an ObjC String Object also called an NSString.

Like I said in the previous part of the guide, ObjC uses what’s called messages to communicate to objects. Here’s two simple example:

[Object method:argument];

[Object method:[Class method]];

The first might be easy to understand. You first have the Object which you want to talk to, then you have the method. The last part is the arguments that the message is sending to the object’s method.

The example under the first one, might look a little harder. It’s exactly the same until you reach the argument part. What you have is “[Class message]”,
which is a simple and common way to get an action done by a method of a class with out making the class an object. I could have done this:

Class * Object2 = [[Class alloc] init]; //I’ll get into “alloc” and “init” later

[Object message:[Object2 message]];

above is the same as:

[Object message:[Class message]];

The great power of ObjC is the ability to use a class with out creating an instance of it. For example, to load an image to be used by an item in the tool bar, you would do this:

[tbOpenFile setImage:[NSImage ImageNamed:@”OpenFile.png”]];

This is a real world message used in many programs to add a graphical image to a tool bar item. The first part is “tbOpenFile”, this is the tool bar item you are accessing. The next part is the method: “setImage”, this will set the image. After that you add to the setImage argument: “[NSImage ImageNamed:@”OpenFile.png”]”, which is a sub message inside a parent message. This sub message uses a class called NSImage and it’s method, ImageNamed, to locate the file OpenFile.png in the Resources folder. In all OS X applications, there is a folder called Resources which holds all the assets for the program.

Next Part:
Finally, we’ll get into the IDE called Xcode, provided by Apple. I’ll show you how to build a basic web browser for the Cocoa application environment; it’s easier than you might think.

HowTo: Mac OS X Application Development Guide, Part 1

This is a series of guides about OS X Programming using Xcode.

Who Should Read This:
This tutorial is written for both beginners and experienced programmers alike. Much of it can probably be skipped by skilled developers. You should at least have good experience with Mac OS X. This first part does not include using OS X yet, and more focuses on the background of OS X programming and the Objective-C language.

For “already” programmers, this guide focuses on people that develop in C, C++, BASIC, Java, and other similar languages.

Organization:
I have split up the categories and concepts into grouped paragraphs to make it easier to skip or navigate through the article. An example of this is right below with the title of the group: “Objective-C and Cocoa“, in bold. I have also highlighted parts of the text with a blue color like this: “example“, for beginning programmers that other developers can pass over. There is also something called “In Depth“, which explains more in detail of something. I have also styled the code examples so they’re easier to read.

Objective-C and Cocoa, a Little Background:
If your a developer who is use to C, C++, Java, and other forms of programming like this then learning how to develop software in OS X might actually seem harder to you than to a novice who’s never programmed before. The reason; OS X uses something know as Objective-C. Objective-C or simply objC, is the primary language for writing OS X applications. It has to be the most odd balled language I have ever used. Now saying that, I don’t mean it’s bad. On the contrary, ObjC is about the most powerful and versatile language I’ve ever used and to a novice it is also the easiest excluding BASIC.

What I’ve realize with ObjC, is that you have to forget the concepts of programming that your use to. It’s not that ObjC by itself is hard to understand, but when mixed with OS X’s primary application environment known as Cocoa it can be.
An application environment in basic terms is the set of frameworks, libraries, programming languages, and other tidbits that build up and run an Application. Sometimes it’s said as “application development environment”, which more specifies to the tools used to make the application.

The new version of OS X(Leopard) has 4 main application environments: Carbon, Cocoa, Java, and BSD. If your using OS X Tiger or lower, then the main application environments you have are: Classic, Carbon, Cocoa, and Java.

This series of tutorials is based around the Cocoa environment. If you would like to program in C++, you should look at Carbon. Carbon was the universal application environment between MacOS 9 and Mac OS X, it has now become an alternative to Cocoa for C++ programmers. Carbon does not contain many of the great features and tools as Cocoa however and your Applications wont fully feel or look like OS X programs. If you are an experienced C++ user, but would like to use Cocoa, you should look into Objective-C++ which I’ll explain in a later part of this guide.

In Depth:
Cocoa was originally created by the company NeXT. At the time, Cocoa was called NeXTStep. If you read my article here, it’ll explain how NeXTStep became OS X. Well NeXTStep was more than an OS, it was also the name of the application environment. Eventually NeXT threw out the OS(the Mach Kernel) and with help from Sun Microsystems, evolved the Application environment into OPENStep. OPENStep was a multi-platform environment that became a competitor to Java. Eventually Apple bought the company NeXT over BeOS, to use it’s OPENStep system as there next evolutionary operating system. Apple then changed the name OPENStep to Yellowbox and there new OS based on OPENStep was called Rhapsody. Yellowbox up until developer release 3 was built to run on Macs, as well as on top of Windows, Linux, UNIX, and Solaris. Do to low developer support, Apple canceled the multi-platform model and instead focused on Rhapsody for Macs. Eventually in 1999 Apple release Rhapsody to the public as Mac OS X Server 1.0. In 2001, Mac OS X 10.0 was released. It took until Mac OS X 10.2 for Apple to finish the x86 version of OS X in 2002, which was never released until 2006 with Tiger. If you still want to use a Cocoa like environment with the Objective-C language to build multi-platform software, look into GNUStep. GNUStep is very much like OPENStep, but is much older and still has an active community.

Along with the NeXTStep environment, NeXT needed a language that was dynamic and powerful. In the end they created an object oriented language called Objective-C. Objective-C in NeXTStep was only two basic frameworks: Application Kit and the Foundation framework. Today, OS X contains over 80 built-in frameworks. This allows more powerful applications and features, but it also makes it harder when you first start learning about Cocoa.

There are some pieces of NeXTStep still in Objective-C and Cocoa. Like for instance, the built in objects have the Prefix “NS”, this stands for NeXTStep. The interface files, that you’ll learn about later have the file extension “NIB”, which stands for NeXTStep Interface Builder. In Mac OS X 10.5 Leopard, Apple has started to faze out these connections. The new NIB format now can have the extension “XIB”, which means Xcode Interface Builder. Xcode is the name of Apple’s development application as well as the rest of the suite that comes with it. Like with Mac OS X, there is only one version of Xcode, and it’s free from Apple here.

Object Oriented(OO) Languages:
An object oriented language or OO is a high-end or high level language. This doesn’t necessarily mean it’s hard, on the contrary this means it’s easier. The higher the level, the more human readable and understandable it becomes. OO languages are about the easiest to learn.

In Depth:
Back in the day people use to program from binary. Binary is the lowest language there is and it is not considered a programming language. Binary is actually a computer language. A computer language is a language that the computer natively understands but a programmer might not. To make it easier to program, new languages that were more human readable were developed. These languages would then translated or compiled into binary for the computer to understand.

Today the languages that replaced the need to program in binary have as well been replaced by languages that are either based from them, or on top of them. This bring in the concept of levels. Binary is at the lowest level, and something like Objective-C is up in a much higher level on top of something known as C.

The most used language in programing is C. Even if you haven’t used C, you might have programmed with a language on top of or based off of C. In the next part of the guide, I’ll explain more about the C language.

Objective-C is a language based off of and on top of C. This means that you can use the C language along with Objective-C. for example:

If(str1==@”hello”) this is C using ObjectiveC variables
{
[str1 setString:@”Hi”]; This is ObjectiveC
}

Another language, C++, is based off of C as well. You can’t directly integrate C++ and Objective-C together, but they can work together indirectly. This indirect way of using C++ and Objective-C together is called Objective-C++. I will get into this more later.

OO languages use a concept in which there or these things called objects. To make it relative to the real world, you can picture an object as a physical item like a house or table. I’ll use “car” as an example Object. A car has assets that contain functions, a few are: a steering wheel, a acceleration peddle, and a brake peddle. These assets, in an object oriented language are called methods and are used to create an action of some sort. A Steering wheel for example creates the action of turning the car left or right. In OO you would create this action through a command or sentence like this:

car.steeringWheel 45

Above is an example written in the BASIC language. First I wrote down the object that will be accessed, then I add a dot. The dot explains that you want to access something in the object. Then I added on the asset, steeringWheel. In OO these assets are called methods. In most object oriented languages you are not allowed to add spaces in side the method’s name. The last part is called an argument. An argument is what you want to tell the method and in turn it tells the object what to do. In the example I tell the object 45. 45 means that that I want the car to rotate 45 degrees to the right. If I said -45, it would rotate 45 degrees to the left. Now for beginners that might be wondering if this object is real, it’s not this is just an example object I just made up out of thin air. Car doesn’t exist in the main language of BASIC.

A great power of OO is the power of hierarchy. Besides Functional assets(methods) like a steering wheel, you can have objects in side objects. So let’s say, to make it easier for programmers to understand how to turn the car object, let’s make the steering wheel an object which has 2 methods. The methods are left and right. Here’s what it would look like:

car.steeringWheel.right 45

Now let’s say that you want to record this rotation value. Then you need to add a property or variable to the object. a property/variable(differently named depending on the language and usage) is like a container that holds information or data. Let’s say there is a Gauge of some sort on the car’s dashboard that shows how much the car’s steering wheel has rotated. We’ll call this swRotateGauge, the “sw” stands for steering wheel. here’s the example again:

car.steeringWheel.right 45
car.swRotationGauge = 45

We just added to the swRotationGauge container, the number 45.
Now most methods and objects will do more than one thing. A normal object in the BASIC language would probably add the two commands above in one like this:

car.steeringWheel.right 45

The above method would rotation the car and add the number 45 to the swRotationGauge on one line. Car is the main object, steeringWheel is the subObject, and right is the method. Again, 45 repersents the argument the programmer gives to the method right.

A Little Bit of ObjC Code:
In this example you’ll see the same action, written in 3 different languages. There will be an object called car. Car has a method called steeringWheel with 2 arguments that turn the car. Read the first two actions, one written in BASIC, the other in C++. See if you can identify what both the arguments mean. Then look at the Objective-C example.

BASIC:
car.steeringWheel 50,10

C++:
car.steeringWheel(50,10);

Objective-C:
[car steeringWheelRotates:50 Speed:10];

In the first example, we are rotating the steering wheel 50 degrees with the object, car, at the speed of 10. The big problem with BASIC, is not knowing anything about the arguments on paper. If you don’t know the arguments you have to look in the reference. Also when someone reads your code, with out knowing the argument names of a method, they might not understand what the code is doing.

In C++, you have the same problem as BASIC, you don’t see the names of the arguments. However, it is strict with the semicolon, which can help advance users organize code better.

When you went down to the third example, you might have been confused. The Objective-C example might not make any sense, or it might have made the most sense. First off you might notice the brackets “[” and “]”. These surround what is called a message. ” [car steeringWheelRotates:50 Speed:10];” is a message. You are sending a message to the object car to rotate the steeringWheel, which in turn turns the car. So now what do you think the method itself is? well this is the method:

steeringWheelRotates:Speed:

In Objective-C, the Methods are split into sections, each section is separated by a colon(”:”), and each section represents an argument. steeringWheelRotates:Speed: is the full method name and the two arguments are steeringWheelRotates: and Speed:. The colons are apart of the name. To compete the arguments, you add the values: positionLeft:50 and Right:50.

Some methods in Objective-C don’t have arguments, if they don’t you just write the name with out any colons like this:

[car turnOn];

BASIC:
car.turnOn

C++:
car.turnOn();

Next Part:
In the next part of the guide, I will explain about the C language(for beginners) and how Objective-C adds to it.

InDepth Mac Compatibility

I’ve worked with many people switching to the Mac platform, and have seen many questions about Mac compatibility. This gave me an idea for this blog post.

Back in the 80s and early 90s, the Apple platform was huge.  The Macintosh platform, that superseded Apple computers, however did not have a good run in the market.  Macs eventually gain ground, but around when Windows 95 came out, it was bought back down again.

Note: for People that never used an Apple, i.e. Apple II, might be confused.  Apple was not just the name of the Company, but the name of the first genre of computers they made.

Many Mac users or just people that have used a Mac around this time switched to Windows completely, and never came back.  Today many of these people have become loyalist to WIndows, some even bashing Macs.  The only problem with this, is that they are bashing Macs from the 90s, not the current one.  One of which is the whole big thing about a one button mouse.  Over time these types of rumors have spread.  One big thing you must understand, is Mac  OS X is not a new version of MacOS 9, it’s a completely different OS.  If you want to know why, see my other blog post here.

Mice/Keyboards:
One big difference with OS X from MacOS Classic is compatibility.  For instance, in the old Mac OS needed drivers for even the simplest things like Mice and Keyboards.  OS X, released in 2001, has something that removes the need of drivers called the I/O Kit.  The I/O Kit allows you to dynamically hook up any mouse with a variable amount of buttons or a standard keyboard. It is also used to create drivers as well.

PDFs, Images, and Vectors:
Mac OS X, uses a technology called Quartz.  Quartz is a graphics engine that renders and composite 2D images based off of Pixar’s Renderman.  Quartz uses a ver simiar system to PDF, so simlar that PDF’s can be opened natively in the OS itself.  Any program that can load or view an image can also show a PDF.  Final Cut Pro, a video editor can even use PDFs just as if it were an image or video on the timeline.  Besides PDFs, Mac OS X understands many forms of images natively.  It is able to do this because of the Quicktime framework.  On Windows, Quicktime is a player, but in OS X, it’s part of the operating system.  The Quicktime library integrates with the Quartz engine, quicktime reads the data and renders it, quartz adds the final touches like anti-alias and shadows, then it composites everything together.  A few image formats OS X understands natively include:  pict(Legacy), jpg, gif, tiff, png, and bmp.

Video and Audio:
Just like with images, video and audio are done through the quicktime library as well.  OS X can understand everything quicktime, this includes:  Mov, avi, flv, and dv.  It can also understand many types of audio files like:  aiff, mp3, MIDI, aac, and wave.

Drivers:
Mac OS X comes with over 2 gigs of Drivers.  These drivers are for printers, video cards, and other odds and ends.  When installing, you can check a box to not include these, or you can go in deeper and tell the installer what brand of drivers not to install.  The OS also comes with a standard set of frameworks to work with firewire or USB devices like hard drives and  Camcorders.  This allows the old feeling of “It just works”.

Quicktime expansion:
Quicktime uses an open architecture allowing plugins to be added for more formats.  Two plugins that a Mac user should get are Flip4Mac and Perian.  Flip4Mac allows quicktime to read and show Windows media files.  If you pay for it it also allows you to convert videos to the windows media format.  Perian, is a army knife of media formats and is a must have.  I’ve used a media player called VLC to play avi’s and divx’s, but it doesn’t stand up to Perian with the Quicktime player.

Microsoft Application documents:
When OS X first came out, it had many problems with reading files from windows.  Today OS X is very compatible with windows files, and besides that Microsoft’s Office document formats are built right into the OS.  You can even use OS X Leopard’s Quicklook feature to browse through a powerpoint presentation.  TextEdit, the application equivalent to NotePad on OS X, can read and write the old, new, and xml formats of Microsoft Word.  Now I don’t mean, TextEdit or any other application can import and export these, I mean OS X natively understands them.  Actually just to show how compatible OS X is, TextEdit can save and open:  plain Text, RTF, HTML, Web Archive, Open Document text(the open standard), Word 2007, Word 97, and word 2003 XML.  If you get Apple’s iWork, you can even work with more formats.  iWork, is Apple’s equivalent to Microsoft’s Office suite.  It comes with Pages(Word publisher), KeyNote(Presentation), and Numbers(Spread sheets).  iWork is completely compatible with MS Office, but MS Office is not fully compatible with iWork.

UNIX, X11, and POSIX:
Steve Jobs once commented in 2001 when OS X was launched, that the Mac OS is now linux like.  This is not the case anymore,  OS X is now not just linux like, but has the certificate showing it is now full UNIX.  This means OS X is above which linux has not gotten to yet.  Anything that now follows the rules and guidelines of POSIX and uses X11 can run in OS X.  That includes not just UNIX, but Linux and BSD applications as well.  In the past, Linux applications had to be recompiled with a little tweak of the code.  Today, many Linux programs work right away in OS X with out you having to recompile the code. Last time Apple’s OS was POSIX compliant was with A/UX(Apple UNIX).

Networking with others:
OS X works with many different operating systems.  Mac OS X Leopard is one of the only operating systems that seamlessly connects many different system together, including Linux, UNIX, and Windows.  OS X Tiger and down also have good compatibility with other operating systems, but Leopard does it so much more.  To connect to other computers(Macs, Windows, etc), it’s as easy as going into the system preferences, and turning on personal file sharing.  OS X finds all computers on the network whether wired or wireless.  After the computer pops up in the finder just click on it and your in., it’s as easy as opening a folder.  OS X Server, unlike Windows Server, can also manage other computers with other Operating systems.

OSes:
Although it appears many people have forgotten, Apple has always been big on software compatibility.  It was once the only operating system that could read both Mac and Dos applications and documents natively.  Later Apple designed a few computers with motherboards that supported two processors.  With this, you could add an intel chip allowing you to run x86 software on the Mac, this was around 1993-1994.  In 1995,  AIM alliance created a powerpc processor that could understand it’s native code along with x86, SPARC, and 68k.  Apple only used this with one computer which was not very successful.  In 1998,  Apple released Rhapsody 5, based off of OPENStep 4.  Rhapsody was designed as an OS for PPC, x86, and SPARC processors as well as an Add-on to the MacOS, Windows, Linux, and Solaris.  Because of low developer support  Rhapsody for other platforms but the Mac faded after Developer release 2.  Rhapsody in 1999 was renamed OS X server 1.0, and then the aqua interface came out in 2000.  In 2001 Darwin, the open source OS by Apple was finally finished and Rhapsody was put on top of it with the name OS X(Darwin was beta until OS X 10.1.1).  After 10 years or so, Apple has finally made the Mac x86 compatible again, but in a different way.  They have completely switched over to Intel after to many problems with IBM’s power4(PowerPC G5) processor.  This means that any operating system that is built for x86 can now run on a Mac.  There are many ways to run UNIX, Linux, and Windows on a Mac.  You can, for instance, use Parallels or VMware which use native virtualization.  Native virtualization means that an operating system is running inside a parent OS on it’s native platform(CPU).  Native virtualization normally can get up to 98% performance out of the OS.  You can also use Apple’s Boot Camp.  Boot Camp is a partitioner.  It splits your hard drive in to two or more with different partition systems so you can run Mac, Windows, and Linux on the same computer.  Boot Camp also installs the needed drivers to run Windows.  Boot Camp is not a virtualization system so it does not have the features that virtual machines have, but it does let you run Windows or Linux at full speed.   PC Magazine, Computer Magazine, and MacWorld Magazine all claim that a Mac is the best computer to run Windows on(as in performance only).  For open source users, WINE is being ported to OS X Leopard.

1 2 3 ... 999999