Quantcast
Channel: Tutorials – onemac – we organise your mac !

Generic Ajax Widget

0
0

As part of this article, I’ve included a generic Ajax widget that simply grabs a URL and parses out a small section of the DOM that I’m interested in.
It’s a good jumping off point to get going with an Ajaxified widget.

Getting Dashcode
If you’ve got a recent version of Leopard or Tiger, the system Disks will contain Dashcode in the developer kit (it may be installed already in your /Developer/Applications directory).

Apple did have Dashcode available for download, but since it expired in July (when Leopard was to come out) it’s no longer there.
You can hunt around the Internet for a old mirror if you don’t have the CDs.
Once installed, it’ll say it’s expired: just get Dashcode working again.


Stability

Broken Dashcode RenderDashcode is particularly ropy with Safari 3.
With Safari 2 it’s much more stable. Since there is the occasional crash from Dashcode,
I would recommend constantly saving your project as you’re coding.
I found more than 10% of the time, Dashcode would crash and result in a total loss of my code from the last save point.

Also, I’ve noticed that dumping a lot to the run log, when viewing the log, can cause Dashcode to slow right down to almost hanging.
Best to avoid dumping large amounts of HTML to the log.

However – and this is a big one – the upside of programming with Dashcode is worth the risk of the crash, because it’s takes most work out of the design process.
Since you’re using it’s GUI to drag and drop your design and how the user will interact with it, rather than having to code the look and feel by hand.

Designing Widgets
The interface and the library component of Dashcode makes it possibly the strongest app for developing widgets. It’s 2 minutes work to create a glass effect on your widget, or to place the elements on the window and get going.
I would strongly recommend studying other widgets, and reading through the Dashcode design recommendations as it’s easy to design a widget that works, but twice the work to design a widget that’s usable and works well.
You’ll find you can place widget-type objects on your widget, like scroll areas or gauges – but to handle them in the code isn’t entirely intuitive, which is why the best source of understand how these interface elements work, is by opening up other widgets that already make use of the element.
Controls

Dashcode offers the easy integration of bespoke elements such as the scrollarea, gauges and other such sexy components.
They’re pretty easy to drop on to the widget from Dashcode, but until you’re coding, they’re not immediately obvious how they work.
The help is limited, so I would recommend to develop by tutorial, in particular, look for the ‘refresh()‘ methods – as this seems to be a fairly standard way to redraw objects.

Full documentation for the Apple classes API is available, but it’s pretty clinical.




Effects
Although effects are available within the Apple classes, you’ll need to implement them yourself.

This is fairly limited to dynamic resizing of the widget, which is achieved using:
window.resizeTo(x, y);
 
If you are going to resize the widget dynamically, check out the Apple resizing examples too.
I used this technique in my HTML entities widget to keep the widget small when it’s dropped in to the Dashboard, but to allow it to grow dynamically when the user searched for a particular HTML entity.
You should be able to find easing effects code and examples if the built in Apple animation class doesn’t suite your needs.
Running system commands
This is one of the few areas that’s well documented in the provided API.

You can run system commands using the following type of command:
widget.system('ps -auxww | grep ' + myCommand, null);
 

What you should keep in mind, is that you can run any command through the system method. This includes Perl, Ruby, AppleScript and anything else that suits your needs.
Using these commands I’ve recently been able to create a widget that queries Mail’s SQLite’s database via Perl.
It was a case of running the system method and capturing the output (and in my case, eval’ing it from a JSON output).

Ajax in the widget
You widget supports a variation of the Ajax object (or rather xmlhttprequest object).
This version isn’t bound by the usual security constraints of a browser – most importantly, it can request content from any domain.
To execute any Ajax requests from your widget, ensure you have the Allow Network Access attribute turned on – otherwise the Ajax will fail without any given reason.
For example, you could use Ajax to pull your film page from IMDb and then parse the XML for the elements of interest.
However, if you do want to pull some data from a web page and process it using the DOM returned you have to fiddle the request – in particular the responseXML will be null because the page being returned isn’t text/xml – it’s text/html. You can do it using the following (in jQuery syntax):
$.ajax({
url: 'http://remysharp.com/example_page', // doesn't really exist!
dataType: 'html', // important
success: function (xml) {
// convert the HTML to an XML DOM object
var dom = getDOMfromXML(xml);
alert(dom.getElementsByTagName('h1').length);
}
});

function getDOMfromXML(xml) {
var d = document.createElement('div');
xml = xml.substring(xml.indexOf('')+1);
xml = xml.substring(0, xml.indexOf(''));
d.innerHTML = xml;
return d;
}
 
This getDOM function is pretty horrible – but it works. I tried using DOMParser and tried using Ajax local data trick and I tried using an iframe to inject the XLM – but neither would load the XML properly (in fact it would be blank).
The iframe would not load properly because it was still loading the entire frame while I was trying to access it.
You can see this in use in the generic Ajax widget or download the source Dashcode project.



Widget Attributes

The widget attributes are fairly self explanatory, but it’s worth knowing:
  • Allow Network Access is required for Ajax requests
  • Allow Command Line Access is required for running external programs, i.e. if you have a Perl script executing some arbitrary task

If you intend to make your widget available in different languages, then this is the place to enter the different strings.

The Inspector

  • Hide items from the default image to present a better widget when it’s installing. It can to keep the preview of your app looking clean.

 

Debugging
Dashcode comes with a log that can be viewed during run time.

You have following debugging tools:
  • Breakpoints
  • Live stack traces
  • Evaluate window – to test commands

To write to the log, you need to use alert("My debug message");.

Dashcode Video Tutorials

Sample Codes for Dashcode

0
0

Dashboard is a display and management system for Mac OS X desktop utilities, called widgets. Developers can create widgets, such as a clock or a calculator,
to provide functionality that doesn’t require the complexity of a large application.

Dashcode Sample Codes:

Hello World
Introductory Dashboard widget example
(HTML)
(DMG)
(ZIP)

Fortune
Deprecated – Demonstrates use of a widget plug-in
(HTML)
(DMG)
(ZIP)
Scroller
Dashboard widget with a DHTML scrollbar implementation
(HTML)
(DMG)
(ZIP)
Birthdays
Dashboard widget with a plug-in that queries AddressBook.framework for contacts with upcoming birthdays
(HTML)
(DMG)
(ZIP)
Fader
Demonstrates fading of elements inside a Dashboard widget
(HTML)
(DMG)
(ZIP)
Goodbye World
Demonstrates display and use of widget preferences to save a widget’s state
(HTML)
(DMG)
(ZIP)
Hello Welt
Demonstrates localization techniques for Dashboard widgets
(HTML)
(DMG)
(ZIP)
Voices
Demonstrates use of the widget.system command from Dashboard
(HTML)
(DMG)
(ZIP)
Resizer
A widget that demonstrates how to use the Apple Animation and Animator classes.
(HTML)
(DMG)
(ZIP)
Syncer
A widget that demonstrates how to use handle a Dashboard Sync event.
(HTML)
(DMG)
(ZIP)

Dashboard 10.4(Tiger) and 10.5(Leopard) Tips:

0
0
Change the Dashboard shelf’s background image:

In 10.4, when you press the ‘+’ symbol in the bottom left corner while Dashboard is active,
the Dashboard shelf slides up into view containing all your widgets.
The background image used for the shelf can be found here:

…System/Library/CoreServices/Dock.app/Contents/Resources/perf.png

You can replace this image with any PNG image you like and it’ll be tiled, or you can use a single, full width image.
The shelf is 118 pixels high and as wide as your monitor (1024 pixels in my case),
so you can use those dimensions to construct your own shelf background.
The bottom area (where the widget names appear) will need to be lighter in color for best results,
as the text is both light and shadowed.
The height of the text area is 14 pixels.
Note also that you do not need to make your PNG file the full width of your monitor —
the image will repeat horizontally if it’s not full-width.

I used a tiny 2KB PNG to create the above full shelf background.

Speed up Dashboard by clearing out its cache:


Over the course of the past few months, Dashboard had become painfully slow for me,
sometimes taking 10 to 20 seconds to load.

I took a look at:

~/Library/Caches/ DashboardClient

…and found that the Dashboard cache was 20MB !!!.
This seemed excessive (plus, I had a fairly recent backup), so I took a gamble and deleted all the files in the DashboardClient folder. Dashboard now loads almost instantaneously for me.

Quickly free memory used by Dashboard widgets:

If you only use Dashboard on rare occasions, and don’t want all those widgets to stay running forever,
try the following AppleScript:

tell application “Dock”

quit

launch

end tell

This will relaunch the Dock and, since all the Dashboard widgets are subprocesses of the dock, they will be closed. Widgets will stay closed until Dashboard is invoked again.

This is a handy way to quickly free up the RAM used by open Dashboard widgets.
Run it, and the RAM is released. Press F12 again after that, and you’ll see that your open Widgets are all still open (you’ll just have to wait through that slight delay as Dashboard ‘activates’ them again).

Detach widgets from the Dashboard:

If you’d like one of your Dashboard widgets to be available all the time, instead of only when you have activated Dashboard via F12, then activate the Dashboard dvelopment mode.
Open the Terminal and type defaults write:
com.apple.dashboard devmode YES

…and press Return. Then logout and log back in again.
Now debugging mode is activated.

To get a widget off of the Dashboard and onto your desktop, just do the following:

1 – Activate Dashboard by pressing F12 (or whatever key you’ve assigned to Dashboard).
2 – Begin dragging the widget.
3 – Press F12 again, before letting up on the mouse button.
4 – Drop the widget wherever you want it.

You can do the same thing in reverse to drag the widget back onto the Dashboard. Also of interest: while a widget is frontmost, you can press Command-R to reload it. (This may be necessary if a widget is buggy and gets messed up somehow.) There’s even a nifty Core Image-based twirl effect to accompany the reload.

However, I find it extremely useful — there are certain widgets that you’d just rather see and use all the time, instead of only in Dashboard mode. Note that the widgets float above all windows, so this trick is most useful if you have some spare desktop space.

To disable this mode, repeat the above command, but replace YES with NO, and then logout/login again. Note that you can also restart the Dock to make the changes take effect (the Dock controls the Dashboard).

Widget Limbo !

When you have dragged a widget out of the Dashboard layer you can make it go into Widget Limbo like this: press and hold the mouse button over the widget; do not move the mouse. Press F12. Release the mouse button.

The widget will now belong outside (beneath) Dashboard, but only be visible (in a darkened state) when Dashboard is active. So it’s not possible to close it nor move it. (Normally you can hold the Option key to close a widget).

Build Web Apps with Dashcode

0
0

When you first launch Dashcode (the easiest way to launch it is through Spotlight), you will see that Dashcode has already created some templates for you to build your Web applications quickly (see Figure 1).

Figure 1: The various templates provided by Dashcode

The best way to learn is to select each template (other than the Custom template) and examine the content of each application. When you have selected a template, examine their contents and press Command-r to test the application on the iPhone Simulator. Go ahead and have fun with each template. When you have enough fun and get yourself acquainted with the environment, come back and we shall create an iPhone Web application from scratch and you will see how each part is built.

Building the UI
Alright, now that you are back, create a new Custom project In Dashcode. Notice that by default, Dashcode created a content and a footer parts for you (see Figure 2). Parts are the various views that you seen on your Web applications, such as buttons, text, etc. For this section, you will create a simple currency convertor Web application for the iPhone.

Figure 2: The parts in the Custom template

Select each of these parts and press the delete key. We shall delete these two parts and add our own parts manually.

Using the Library (Window’Show Library), drag-and-drop a Stack Layout part to the design surface (see Figure 3).

Figure 3: Using the Library to drag and drop parts onto your application

Expand the stackLayout part and you should see that it contains two subviews – view1 and view2. Select view1 and change its size to 320px by 356px (see Figure 4) via the Inspector window (Window’Show Inspector). Do the same for view2.

Figure 4: Changing the size for view1 and view2 via the Inspector window

Double-click on view1 and rename it as mainScreen. Do the same for view2 and rename it as settings (see Figure 5).

Figure 5: Renaming the two subviews

In the Library, drag-and-drop the Rounded Rectangle Shape part onto the mainScreen view (see Figure 6).

Figure 6: Adding the Rounded Rectangle Shape part to the subview

It its Inspector window, select the Fill & Stroke tab and in the Style tab select Gradient fill (see Figure 7) and select two colors.

Figure 7: Using the gradient fill to fill the part

Select the Effects tab and check the Glass and Recess checkboxes (see Figure 8).

Figure 8: Adding glass effect to the part

Select the Metrics tab and select the Absolute layout (see Figure 9).

Figure 9: Using absolute layout for parts positioning



Add the following parts to the Rounded Rectangle Shape part (see Figure 10) and name them as:

Text
TextField
Pop-up Menu
Push Button

    Figure 10: Adding additional parts to the subview

    Select the settings subview and repeat the same steps you have performed above. Figure 11 shows the parts added to the settings subview.

    Figure 11: Populating the settings subview

    You are now ready to view the application on the iPhone Simulator. Press Command-r to view the application on the iPhone Simulator (see Figure 12). Notice that the application is hosted by mobile Safari on the iPhone.

    Figure 12: Click ‘Run’ toView the application on the iPhone Simulator

    Notice that you can only see the mainScreen subview. To see the settings subview, you need to write some code to navigate to it from the mainScreen subview.


    Coding the Application
    So you are now ready to write some code. With the mainScreen subview selected, right-click on the Settings button and select Events’onclick (see Figure 13).

    Figure 13: Creating an event handler for the onclick event

    You will be asked to name the event handler for this event. Name it as shown in Figure 14.

    Figure 14: Naming the handler for the event

    Notice that the code editor now appears at the bottom of the designer (see Figure 15).

    Figure 15: The code editor where you can add your code

    Enter the following code:

        function btnSettings_ClickHandler(event)
        {
            var views = document.getElementById(‘stackLayout’);
            var settings = document.getElementById(‘settings’);
            if (views && views.object && settings) {
                views.object.setCurrentView(settings);
            }
        }

    Select the settings subview and right-click on the Save Settings button and select Events’onclick. Name the handler as btnSave_ClickHandler. Enter the following code:

        function btnSave_ClickHandler(event)
        {
            var views = document.getElementById(‘stackLayout’);
            var front = document.getElementById(‘mainScreen’);
            if (views && views.object && front) {
                views.object.setCurrentView(front, true);
            }
        }

    Test the application again by pressing Command-r. This time, you will be able to navigate to the settings view by tapping on the Settings button in the mainScreen subview (see Figure 16).

    Figure 16: Tapping on the Settings button navigates to the settings subview

    Database Access
    So far, your application displays two screens where you can perform some currency conversion as well as set the exchange rates for the different currencies. For simplicity, I am going to assume that you are converting the currencies into Singapore Dollars (SGD). All the exchange rates would be based on the SGD as the base currency.

    To allow the users to store their own exchange rates, you will make use of the local database feature as defined in HTML 5 (which is supported by Mobile Safari). Doing so allows users of your application to store the exchange rate locally on their iPhones.

    In the main.js file, add the following lines of code for performing database operations:

        var database = null;                           // The client-side database
        var DB_tableName = “CurrencyKeyValueTable”;    // database name

        // Function: initDB() – Init and create the local database, if possible
        function initDB()
        {
            try {
                if (window.openDatabase) {
                    database = openDatabase(“ExchangeRatesDB”, “1.0”,
                                            “Exchange Rates Database”, 1000);
                    if (database) {
                        database.transaction(function(tx) {
                            tx.executeSql(“SELECT COUNT(*) FROM ” + DB_tableName, [],
                            function(tx, result) {
                                loadRates();
                            },
                            function(tx, error) {
                                // Database doesn’t exist. Let’s create one.
                                tx.executeSql(“CREATE TABLE ” + DB_tableName +
                                ” (id INTEGER PRIMARY KEY,” +
                                ”  key TEXT,” +
                                ”  value TEXT)”, [], function(tx, result) {
                                    initRates();
                                    loadRates ();
                                });
                            });
                        });
                    }
                }
            } catch(e) {
                database = null;
            }
        }

        // Function: initRates() – Initialize the default exchange rates
        function initRates()
        {
            if (database) {
                database.transaction(function (tx) {
                    tx.executeSql(“INSERT INTO ” + DB_tableName +
                        ” (id, key, value) VALUES (?, ?, ?)”, [0, ‘USD’, 1.44]);
                    tx.executeSql(“INSERT INTO ” + DB_tableName +
                        ” (id, key, value) VALUES (?, ?, ?)”, [1, ‘EUR’, 2.05]);
                    tx.executeSql(“INSERT INTO ” + DB_tableName +
                        ” (id, key, value) VALUES (?, ?, ?)”, [2, ‘AUS’, 1.19]);
                });
            }
        }

        // Function: loadRates() – Load the currency exchange rates from DB
        function loadRates()
        {
            var element;  
            var popUpElement = document.getElementById(‘popupConvertTo’);

            if (database) {
                database.transaction(function(tx) {
                    tx.executeSql(“SELECT key, value FROM ” + DB_tableName, [],
                    function(tx, result) {
                        for (var i = 0; i
                            var row = result.rows.item(i);
                            var key = row[‘key’];
                            var value = row[‘value’];

                            //—populate the pop-up menu part—
                            popUpElement.options[i].text = key;
                            popUpElement.options[i].value = value;

                            if (key == ‘USD’) {
                                element = document.getElementById(‘txtUSD’);
                            }
                            else {
                                if (key == ‘EUR’) {
                                    element = document.getElementById(‘txtEUR’);
                                }
                                else if (key == ‘AUS’) {
                                    element = document.getElementById(‘txtAUS’);
                                }
                            }
                            element.value = value;
                        }
                    },
                    function(tx, error) {
                        showError(‘Failed to retrieve stored information from database – ‘ +
                            error.message);
                    });
                });
            }
            else {
                loadDefaultRates();
            }
        }

        // Function: saveRates() – Save the currency exchange rates into DB
        function saveRates()
        {
            if (database) {
                var elementUSD = document.getElementById(‘txtUSD’);
                var elementEUR = document.getElementById(‘txtEUR’);
                var elementAUS = document.getElementById(‘txtAUS’);

                database.transaction(function (tx) {
                    tx.executeSql(“UPDATE ” + DB_tableName + ” SET key = ‘USD’,
                        value = ? WHERE id = 0″, [elementUSD.value]);
                    tx.executeSql(“UPDATE ” + DB_tableName + ” SET key = ‘EUR’,
                        value = ? WHERE id = 1″, [elementEUR.value]);
                    tx.executeSql(“UPDATE ” + DB_tableName + ” SET key = ‘AUS’,
                        value = ? WHERE id = 2″, [elementAUS.value]);
                });
            }
            loadRates();
        }

        // Function: deleteTable() – Delete currency exchange table from DB
        function deleteTable()
        {
            try {
                if (window.openDatabase) {
                    database = openDatabase(“ExchangeRatesDB”, “1.0”,
                                            “Exchange Rates Database”);
                    if (database) {
                        database.transaction(function(tx) {
                            tx.executeSql(“DROP TABLE ” + DB_tableName, []);
                        });
                    }
                }
            } catch(e) {
            }
        }

        // Function: loadDefaultRates() – Load the default exchange rates
        function loadDefaultRates()
        {
            var popUpElement = document.getElementById(‘popupConvertTo’);
            var element = document.getElementById(‘txtUSD’);
            element.value = “1.44”;
            popUpElement.options[0].text = “USD”;
            popUpElement.options[0].value = element.value;

            element = document.getElementById(‘txtEUR’);
            element.value = “2.05”;
            popUpElement.options[1].text = “EUR”;
            popUpElement.options[1].value = element.value;

            element = document.getElementById(‘txtAUS’);
            element.value = “1.19”;
            popUpElement.options[2].text = “AUS”;
            popUpElement.options[2].value = element.value;
        }

    The database code above is pretty straightforward – store the exchange rates inside the database and populate the pop-up menu part when the rates are retrieved.

    Modify the load() function as follows:

        //
        // Function: load()
        // Called by HTML body element’s onload event when the Web application is ready to
        // start
        //
        function load()
        {
            dashcode.setupParts();

            initDB();   
            if (!database) {
                loadDefaultRates();
            }
        }

    Press Command-r to test the application. When the application is loaded, the pop-up menu will now display the three different currencies (see Figure 17).

    Figure 17: The pop-up menu part displaying the different currencies

    When you tap on the Settings button, the exchange rates would also be displayed in the settings subview (see Figure 18).

    Figure 18: The exchange rates displayed in the settings subview

    Performing the Conversion
    You are now ready to perform the actual conversion of the currencies. In Dashcode, select the mainScreen subview and right-click on the Convert! Button and select Events’onclick (see Figure 19).

    Figure 19: Handling the onclick event for the Convert! button



    Name the event handler as btnConvert_ClickHandler and code it as follows:

        function btnConvert_ClickHandler(event)
        {
            var amount = document.getElementById(“txtAmount”).value;   
            var rates = document.getElementById(“popupConvertTo”).value;
            var result = amount * rates;
            alert(result);
        }

    Press Command-r to test the application. Enter an amount and select the currency to convert. Tapping on the Convert! button will now display the amount converted (see Figure 20).

    Figure 20: Try converting some currencies!

    Converting your Web Application into an iPhone Native Application
    Now that your application is completed, you may deploy your application onto a Web server so that users can access your application through the Safari browser on their iPhones. However, since this is a Web application, the user must have access to the Internet, or else there is no way to access your application. And since our application does not make use of any server-based data, it is a good candidate to convert into a native iPhone application. The easiest way would be to host the Web application within the Safari browser, which is represented by the WebView view in the iPhone SDK.

    In this section, I will show you how you can convert an iPhone Web application into a native iPhone application.

    First, deploy your Web application by clicking the Share item in Dashcode (see Figure 21). Click the Deploy button so that all the files of the application will be saved to a Web publishing directory. Take note of the Web publishing directory shown in Dashcode. It is saved in /Users//Sites/CurrencyConvertor/. You will make use of the files contained within this folder shortly.

    Figure 21: Deploying a Web application in Dashcode
    • Launch Xcode and create a new View-based Application project. Name the project as CurrencyConvertor.
    • In Finder, navigate to the /Users//Sites/CurrencyConvertor/ folder and select the files shown in Figure 22.
    Figure 22: All the project files created by Dashcode

    Drag-and-drop all the selected files onto the Resources folder in Xcode. Xcode will prompt you with a dialog (see Figure 23). Check the Copy items into destination group’s folder (if needed) checkbox and click Add.

    Figure 23: Adding all the Dashcode files into the Resource folder in Xcode

    Perform a global Find-and-Replace (by pressing Shift-Command-F). Search and replace the following strings with an empty string (see Figure 24):

    Parts/
    Images/


    Figure 24: Replacing all instances of “Parts/” and “Images/” with an empty string

    This will update the various HTML and JavaScript files that reference other files using the Parts/ and Images/ folder. Files stored in the Resources folder of your Xcode application have no directory structure when they are deployed; hence all the files are in a flat directory.

    Select the files shown in Figure 25 and drag-and-drop them onto the Copy Bundle Resources (16) folder. This will ensure that all the HTML, JavaScript, CSS, and images files will be deployed together with your application.

    Figure 25: Copying all the Web files into the targets folder so that they are deployed together with your application


    In the CurrencyConvertorViewController.h file, add the following statements to define an outlet:

        #import

        @interface CurrencyConvertorViewController : UIViewController {
            IBOutlet UIWebView *webView;
        }

        @property (nonatomic, retain) UIWebView *webView;

        @end


    Double-click on the CurrencyConvertorViewController.xib file to open it in Interface Builder.
    Add a WebView view to the View window and control-click and drag the File’s Owner item to the WebView view (see Figure 26). Select webView.

    Figure 26: Connecting an outlet to a view

    In the CurrencyConvertorViewController.m file, add the following statements:

        #import “CurrencyConvertorViewController.h”

        @implementation CurrencyConvertorViewController

        @synthesize webView;

        – (void)viewDidLoad {
            NSString *path = [[NSBundle mainBundle] pathForResource:@”index”
                                ofType:@”html”];
            [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath: path
                                    isDirectory:NO] ]];
            [super viewDidLoad];
        }

    That’s it! Press Command-r to test the application on the iPhone Simulator. The Web application is now hosted within the WebView view (see Figure 27). What you have just done is convert a Web application into a native application!

    Figure 27: Running the Web application as a native iPhone application

    RSS Feed Reader Widget !

    Dashboard Widget Tutorial

    0
    0

    This tutorial walks you through using Dashcode to create a Dashboard widget. As you follow the steps, you learn how to choose a widget template, customize your widget’s appearance and code, and share your widget with others. Completing this tutorial is a quick and easy way to get started building Dashboard widgets in Dashcode.

    This document includes two additional tutorials, “Mobile Safari Web Application Tutorial” and “Dual-Product Web Application Tutorial,” which follow this one. The remainder of the document delves more deeply into the Dashcode development environment, describing how it supports both widget and web application development. If you don’t want to learn how to create a web application, you can continue learning more about Dashcode by reading “Starting a Project.”

    Before You Begin !

    In this tutorial, you build a Dashboard widget that counts down to your birthday, similar to the widget shown in Figure 1-1.

    Figure 1-1  The Birthday widget

    Before continuing, make sure that you have Dashcode installed on your Mac (the location is /Developer/Applications/). If you don’t have Dashcode installed, read “Getting and Running Dashcode” to learn how to get and install Dashcode.



    Choose a Template

    To start, double-click the Dashcode icon to open it. A new project window opens and displays a dialog in which you first select the type of project you’re interested in—in this case, Dashboard—and then, the kind of widget you want to create from an assortment of templates. Templates are handy starting points for creating common types of widgets. Select a template’s icon to show a short description of what that template does.

    To make the Birthday widget, this tutorial uses the Countdown template. Select its icon and click Choose. A project window opens with a new widget based on the Countdown template, as shown in Figure 1-2.

    Figure 1-2  A project window showing a new Dashboard widget

    Along the left side of the project window is the navigator, which you use to switch between the various tools available when you’re designing a widget. The main portion of the window is the canvas, which you use to design your widget’s interface.

    At the bottom of the navigator in Figure 1-2 you can see the Workflow Steps list, which guides you through the widget development process. Each step is a milestone in creating a widget, telling you what to do and where to do it. When you complete a step, mark it as done and move on to the next step.

    Note: If you don’t want to see the Workflow Steps list, you can hide it by choosing View > Steps or by clicking the button that looks like a checkbox at the bottom edge of the project window (this button is highlighted in Figure 1-2).
    Alternatively, you can view a list of the widget’s files in place of the Workflow Steps list. If you want to see the Files list, choose View > Files or click the list button in the bottom edge of the project window (it’s the button that looks like a bulleted list).
    Set the Target Date

    The Countdown template gives you a Dashboard widget with all the elements and code needed to count down to an event. All you need to do is tell the widget the target date. To set the target date, select Widget Attributes in the navigator. The canvas is replaced by the widget attributes pane, in which you specify important values that your widget needs.

    In the Properties section of the widget attributes pane, choose Date and Time in the Target Kind pop-up menu and enter the date of your next birthday, as shown in Figure 1-3.

    Figure 1-3  The Countdown template’s properties

    Test the Countdown

    Your new Dashboard widget is already fully functional. To prove this, choose Debug > Run to run the widget. Dashcode can run a widget without opening it in Dashboard, making it a handy place to test your widget and fix any problems you encounter. After the widget loads, it starts counting down towards your next birthday.

    When you’re satisfied that your widget is working as you expect, choose Debug > Stop to stop it.

    Now is a good time to save your widget project. Choose File > Save to save the project. Give your project a name and select a location to save it in. Your widget is saved in a widget project that encapsulates the widget and information Dashcode needs to create the widget for you.

    Customize the Widget’s Appearance

    Although you now have a fully functioning Dashboard widget that’s ready to share, you might want to personalize it to make it unique. Dashcode’s design tools make it easy to customize your widget’s interface. Select the widget item in the navigator (it should display the name you gave it when you saved the project). The widget attributes pane is replaced with the canvas.

    First, change your widget’s body color. Select the widget body (also called the front image or frontImg) on the canvas and then choose Window > Show Inspector. The inspector window allows you to modify a selected element’s properties, such as its appearance and behavior. Click the Fill & Stroke button at the top of the inspector window (it’s the second from the left). If it’s not already selected, click the Style tab to reveal fill, stroke, corner roundness, and opacity values. Click the color well and choose a new color in the Colors window that appears. Try different fill styles until you find a combination that you like. If you want to try changing other effects, such as the glass appearance, click the Effects tab to reveal these values, as shown in Figure 1-4.

    Figure 1-4  Tweaking the front image using the Fill & Stroke inspector

    When you’re finished customizing your widget’s body, add a photo of yourself from iPhoto to the widget. Your iPhoto library is available from the Library window. To show your iPhoto library, choose Window > Show Library; then click the Photos button. Find a photo and drag it to your widget on the canvas. Resize it by dragging any of the resize handles on the photo.

    Finally, change the Event Label text to something like “…days until my birthday.“ You can do this by selecting the Event Label text, clicking the Attributes button in the inspector window (it’s the leftmost button), and entering the text in the Value field, or by double-clicking the text in the widget body itself and entering the new text.

    Add Functionality Using Parts

    Now that you have a personalized Dashboard widget that counts down to your birthday, add a button that, when clicked, shows the Apple Store (so your friends and family can buy you a birthday present!). To add a button to your widget, use a button part. Parts are controls and views used on a widget’s interface.

    To find a button part, choose Window > Show Library and click Parts. You can use the search field at the bottom of the window to help you find a particular part or type of part. From the list of parts, drag the Lozenge Button part from the Library window to your widget’s body. Double-click the button to select its label text, enter the text “Buy me a gift” and press Return. You’ll probably need to resize the button to fit the new label.

    Write Code to Show the Apple Store

    To make the button take the user to the Apple Store when it’s clicked, you need to add a behavior to the button. In the inspector window, click the Behaviors button (it’s the rightmost button). This shows the Behaviors pane, in which you assign handler functions to events on an object. Select the button on the canvas and double-click in the Handlers column next to the onclick event name. Enter the name of a new function, such as showAppleStore, and press Return. Click the arrow next to the function name you entered to reveal the source code editor below the canvas. Here you write code to add functionality to your widget. Clicking the arrow reveals the showAppleStore function Dashcode inserted in your widget’s code. Between the braces ({ .. }) enter the following line of code:

    widget.openURL(“http://store.apple.com/”);


    The code in the source code editor should look like that in Figure 1-5.

    Figure 1-5  A function in the source code editor

    Test your widget again by choosing Debug > Run. Click the button you added and make sure a new Safari window opens with the Apple Store website displayed. Be sure you save your project often to preserve the changes you make.

    Deploy Your Widget

    Congratulations! You’ve created your first complete Dashboard widget using Dashcode.

    To open your widget in Dashboard, choose File > Deploy Widget. Click Install in the dialog that appears to view your widget in Dashboard.

    To share your widget with the world, select Run & Share in the navigator. The pane that appears displays the widget project name you chose in “Test the Countdown,” but you can replace this with a different name if you want. You can also set the minimum version of Mac OS X your widget should run in. Click Save to Disk to save your widget. You can now email it to friends or post it on your webpage. You can use the File > Compress command in the Finder to archive it.

    Game Development – Tutorials

    0
    0

    Unity Widgets

    Building
    Besides regular Mac apps, Unity can build MacOSX widgets, using the Unity web plugin.

    Customization

    The widgets are just a web player wrapped with the widget HTML. If you right/option-click on the .wdgt file and select Show Package, you’ll see the generated Unity file and accompanying HTML, CSS and images. Any additional files loaded by the widget can be added in the widget. For example, this widget streams a movie, cat.ogv.
    You will probably want to customize the default Unity build by replacing the Icon.png file, which is the icon that displays in the Dashboard dock. Version information can be adjusted in the Info.plist file. You can customize the back panel by modifying the HTML and CSS files.

    Publishing
    Most widgets are submitted and listed on the Apple widget download page. Most widgets are free, though some are listed as shareware. If a widget is listed as a Staff Favorite or Featured Widget, it certainly ends up in the Top 50.

    Widgets published include HyperBowl Classic, FuguBowl, FuguMaze, FuguTilt, FuguFlip, Fugutype…
    Other Unity widgets include 3D Paradise Paintball, MacPinball, Banana Warehouse and Blingy.

    References
    See the Apple Dashboard developer article for an overview of widget and links to more articles.


    Build a Safari Extension

    0
    0

    The best place to start with any new programming job is a simple “Hello World.” With this walkthrough for creating a basic Safari extension, we’ll create a skeleton to build a toolbar button from. If you know HTML, CSS, and JavaScript, you are already 95 percent of the way to your first Safari extension.

    Get Registered
    Safari Extensions need to be signed to be installed, so before writing any code, head over to the Safari Developer Center to register as a Safari Developer. It’s free to join, and binds to your Apple ID from your MobileMe or iTunes account. You will have to follow the steps in the online wizard to create your own signed certificate, which you’ll use to create your extension. Once the certificate is created, just double-click to install it. Safari will automatically use this certificate when building your extensions.

    Enable the Develop Menu & Extensions
    Building Safari Extensions starts inside of Safari, but to get there you have to enable the Develop menu. To do so, go to Safari Preferences, select the “Advanced” tab on the end, then check the last option on the page, labeled “Show Develop menu in menu bar.”

    You’ll see the new menu appear, click on it, check “Enable Extensions,” and select “Show Extension Builder.”

    Create a New Extension
    In the Extension Builder, click on the plus sign in the bottom left hand corner, then select “New Extension.” Choose a place to put the source code for your extension; I always put my code in a “Code” folder under my home directory. Give it a meaningful name, like “Hello World.” In the new form, fill out the “Extension Info” section, and change the Bundle Identifier under “Extension Details” to com.theappleblog.helloworld. Under “Extension Website Access” set “Access Level” to All, and check “Include Secure Pages.”

    Open the Project Folder
    This is where it gets a little confusing. It seems like Apple would like you to be able to build the entire extension in Safari, but they only give you half the tools to do it. The next option on the list is “Extension Global Page,” in a drop down menu, but there is no option to create one. Once the extension project folder is created (it’ll be in that folder you selected when you created your new extension), you need to open it up and add a couple of files to it. Since we are building a toolbar extension, you will need two files: an image in PNG format, and an HTML file which will hold our JavaScript. You can download both the HTML and the PNG file to use here. Add those two files to the project folder, and switch back to the Extension Builder. Now, when you click on the drop down menu under Extension Global Page, you should see the option for “global.html”, go ahead and select that.

    Next, in the “Extension Chrome” section, click the “New Toolbar Item” button. That should drop down a new form with seven options. Fill out the form like this example:

    Write Some Code
    Open the global.html file in your favorite text editor. In this file is all of the logic for the extension. When our icon on the Safari toolbar is pressed, it will send an event named “sayHello”. Safari will parse our global.html file and see if that event is defined. Since we are checking for that event with the line if (event.command === “sayHello”), our JavaScript will trigger whenever that button is pressed. It’s important that the command defined in the Extension Builder matches the event.command we are looking for in global.html. When the event is matched, Safari will run any JavaScript inside the if statement which, in our case, is a simple alert box.

    If you are familiar with JavaScript, you’ll be able to tell right away what you can do here. If not, just know that you can replace the line alert(“Hello World”); with whatever valid JavaScript you’d like.

    With the Toolbar Items menu is filled out, you should be ready to build the extension. Click on the “Build Package” button in the top right corner of the Extension Builder. Save the extension to your desktop, then double-click on it to install it in Safari. You should notice a new button on the toolbar sporting the nifty TAB logo. Click on it, and you should see an alert window pop up saying hello.

    Debug Workflow
    If you don’t already have the global.html file open, go ahead and open it in your favorite text editor again. Change the text of the alert to say “Hello Jon,” or whatever you would like. Save the file without closing the text editor, then switch back to the Extension Builder and click “Reload.” Now switch to Safari and hit your button again, it should now display the new text in the alert window.

    Build Something Awesome
    This article has barely scratched the surface of what Safari Extensions can do. For more in-depth information, read through the Developers Guide on the Apple web site

    Build a Safari Extension – Videos

    MacWall Tips

    0
    0
    1. Get The Right Resolution
    Regardless of its artistic beauty, a wallpaper that doesn’t come in a high enough resolution and matching aspect ratio will look grainy and distorted. To avoid awkward looking background images, you should understand the specs of your monitor before you start hunting for great wallpapers.
    Screen resolutions are denoted in pixels, e.g. 800 x 600. The numbers indicate how many pixels your monitor can display horizontally (800) and vertically (600). The resolution also reveals that the monitor in this example has an aspect ratio of 4 : 3 (horizontal : vertical pixels).
    A perfect wallpaper has to meet two criteria:
    1. high enough resolution
    2. matching aspect ratio
    This article from CrunchGear provides a resolution chart (depicted below) that lets you pick the right wallpaper aspect ratio and resolution for your monitor. For example, if your monitor has a resolution of 1600 x 1200 you have a 4:3 aspect ratio. This ratio is color-coded red, so you can use all resolutions in red that are 1600 x 1200 or greater.
    So how do you find out your monitor’s native resolution and aspect ratio?
    Windows 7
    Right-click on the desktop and select > Screen resolution from the menu and look for the number next to > Resolution:
    Windows XP
    Right-click on the desktop, select > Properties from the menu and switch to the > Settings tab. You’ll see a slider under > Screen resolution in the bottom left.
    2. Find the Most Beautiful Wallpapers
    The amount of websites that offer free wallpapers is endless. Fortunately, you came to the right place and we have already done some weeding out for you. You can either get some fresh wallpapers from our themed compilations or find your own favorites in the resources we have covered.
    Wallpaper Compilations:
    Wallpaper Resources:
    3. Shuffle Your Wallpapers
    Now that you have skimmed through all those resources, you’re left with dozens of wallpapers you like and you cannot make up your mind. Don’t despair because you don’t have to! Rather than settling for just one wallpaper, why not use all of them?
    Windows 7
    If you have Windows 7 Home or up, you can personalize your computer and that includes your desktop. Right-click on the desktop and select > Personalize. In the bottom left of the window that opens click on > Desktop Background. From > Picture Location: select the folder where you stored your wallpapers or click > Browse… to add a custom folder. Select all the images you want to use, then select the > Picture position define to > Change picture every… and check > Shuffle to not see the same sequence every time. Finally click > Save Changes and enjoy.
     
    Windows XP
    Windows XP doesn’t offer an inbuilt tool to shuffle your wallpapers. However, there are many third party applications that can do that trick. I have been using ScrollWall and I also like John’s Background Switcher. Another super fascinating wallpaper tool with a social twist is Wallcast
    All aforementioned applications and several more are described in these articles:
    4. Create An Unobstructed View Of Your Wallpaper/s
    So you have this fantastic wallpaper or maybe you have already set up shuffling, but what is it that you see on your desktop? Lots of icons! To really enjoy the view, you need to get rid of them! BEFORE vs AFTER IMAGE I have written two articles that will guide you to a beautifully organized and minimalist desktop:
    5. Get An Animated Desktop Wallpaper
    My final advice should be: keep it simple. However, if you have resources to spare, go ahead and get yourself an animated desktop wallpaper. In Windows 7 you can use your screensaver as a wallpaper. To use a video of your own you have to convert it to an .scr (screensaver) file.
    Windows 7
    Windows XP

    Change your Screen Saver

    0
    0

    Your desktop picture is the most high-profile item on your computer. Likewise, your screen saver is the most high profile item when you’re not. And like the desktop picture, you can change the default screen saver, use your own slideshow creation, or use a third-party screen saver.

    To swap your current screen saver for another one:

    Mac OS X contains several preinstalled screen savers
    1. From the Apple menu, choose System Preferences to open the System Preferences window.
    2. Click the Desktop & Screen Saver button to display its preferences.
    3. Click the Screen Saver tab to display just the Screen Saver preferences. All installed screen savers appear in the left pane. The right pane displays a preview of the selected screen saver.
    4. Click one of the Screen Saver items in the left pane to select it for use.
    5. If you’d like, click Test to see what the screen saver will look like in use.

    To create a slideshow screen saver, do one of the following:

    By selecting Library, your Mac will automatically create a slideshow screen saver made from your iPhoto pictures.
    1. In the Screen Saver preferences window, select Library or one of the two choices below it to turn your iPhoto images into a slideshow screen saver.
    2. In the Screen Saver preferences window, select Pictures Folder to display the images in it, or select Choose Folder, navigate to and select a folder that contains images in the resulting dialog, then click Choose to put it in use.

      To add a third-party screen saver:

      Once you install a third-party screen saver, either through an installer or manually,
      you can select it just like you would with the preinstalled ones.
      1. If the screen saver doesn’t have an installer to place the file in the right folder, locate the .saver file in the package.
      2. Drag the file into the Screen Savers folder, which is in the Library folder at the root of your hard disk ~/Library/Screen Savers.
      3. Follow the steps in “swap your current screen saver for another one,” above, to select the third-party screen saver.

      Customize your Screen Saver
      Now that you’ve selected a new screen saver, you can further customize its settings. Here are some of the things you can do in the Screen Saver preferences window.

      1. Click Options to view the selected screen saver’s user-configurable display settings and adjust them to your liking. These settings will vary screen saver to screen saver.
      2. Move the “Start screen saver” slider left or right to change the time, in minutes, at which the screen saver begins to play.
      3. If you’d like the ability to start the screen saver manually, click Hot Corners. In the resulting dialog, choose Start Screen Saver from any of the four corner pop-up menus and click OK. The screen saver will start when you move your arrow to your chosen screen corner.
      4. If you’re the adventurous type, select “Use random screen saver,” and your Mac will automatically select a screen saver when it goes into screen saver mode.

        Use Photos from iPhoto !

        0
        0

        Use your Mac Desktop as a large digital frame of sorts. You can show favorite pictures from albums you’ve created in iPhoto, and have them change every so often, too.

        Open System Preferences (in the Apple menu). Click Desktop & Screen Saver (in the first row). This will bring-up settings for Desktop wallpaper and Screen Saver. Then, click the Desktop tab.

        If the left column of the settings windows, you’ll see a number of folders from which you can choose images to be displayed on the Mac Desktop.

        Toward the bottom of the list, iPhoto Albums is listed. Click the triangle to view the albums you’ve created in iPhoto. Select one of the albums. Your Desktop will change instantly, displaying a photo from the album.
        Now, in the same window, check the “Change picture” setting and choose when or how often you’d like the Desktop wallpaper to change. For example: every 30 minutes. You can click the “Random order” setting to have the next Desktop picture randomly selected from the iPhoto album.

        One final finesse. In the settings window, above the thumbnail photos, you can specify how you’d like the photo to display on the Desktop: Fit to Screen, Fill Screen, Stretch to Fill Screen, Center and Tile. Play with the options and select what you like best.

        Xcode Development

        0
        0

        NSTableView class to create a single column table view

        1. Create an Xcode project

        • Step 01: Launch Xcode 3.0 and create a new project by clicking on File ⇒ New Project.
        • Step 02: Select Application ⇒ Cocoa Application and click on the Next button.
        • Step 03: Specify the Project Name and Project Directory as follows:
        • Project Name: SingleColumnTableView
        • Project Directory: ~/Documents/Project/XCode/Tutorial/SingleColumnTableView/
        • Click on the Finish button.

        This will bring up the Project window.

        2. Edit the NIB file

        • Step 01: In the Groups & Files browser, expand the NIB Files folder and double click the MainMenu.nib file.

        This will launch the Interface Builder application and open the following windows:

        • a. Interface Builder NIB file browser
        • b. Interface Builder Inspector
        • c. Interface Builder Library
        • d. Application Main Menu window
        • e. Application Window

        3. Create a controller class

        • Step 01: Use Xcode to create the application controller class. In the Groups & Files browser, right click on the Classes folder ⇒ Add ⇒ New File.
        • Step 02: Select Cocoa ⇒ Objective-C class and click on the Next button.

        Specify a name for the application controller class and click on the Finish button.

        • Filename: ApplicationController.m

        You should now be able to see the files for the ApplicationController class will be automatically added to the Xcode project.

        Double click on the ApplicationController.h file to view its interface specifications.

        Double click on the ApplicationController.m file to view its implementation details.

        • Step 03: Click on the Interface Builder icon to bring it to the foreground. Using the Interface Builder Library, select Objects & Controllers ⇒ Controllers ⇒ NSObject and drag it to the Interface Builder NIB file browser.

        Using the Interface Builder Inspector, specify the following information:

        • Class Identity ⇒ Class: ApplicationController
        • Interface Builder Identify ⇒ Name: ApplicationController

        Because Interface Builder is automatically synchronized with Xcode, you can see the ApplicationController class that was previously created in Xcode, in the drop-down list box for the class identify.

        You should now be able to see the reference to the ApplicationController class in the NIB file browser as shown below.

        • Step 04: Specify an action that the application controller class can respond to.

        Go to Class Actions, click on the button and specify an action called update:

        • Step 05: Specify an outlet that will be used by the application controller class to communicate with the target table view object.

        Go to Class Outlets, click on the button and specify an outlet called tableView.

        Leave the tableView type as id for the moment. The tableView type will be changed to NSTableView later on.

        4. Create a table view and link it to the application controller class’ outlet

        • Step 01: Using the Interface Builder Library, click on the Objects tab and select the Views & Cells ⇒ Data Views folderr
        • Step 02: Drag and drop an NSTableView object from the library to the application window. Resize the NSTableView object so that it is correctly positioned within the window. Leave a little space at the bottom of the window, so that we can later on, add a button to update the table view contents.
        • Step 03: Since we’re going to create a single column table view, we will need to delete the second table column using the Interface Builder NIB file browser.

        Expand the Window (Window) object till you reach the Table View node.

        Select the second Table Column and delete the object using the menu option Edit ⇒ Delete.

        Your application window should now contain a single column table view.

        • Step 04: Slowly click on the NSTableView object twice, to select the Table View object.

        The first click will select the Scroll View object and the second click will select the Table View object. The Table View will be highlighted as shown below.

        Ctrl+drag from the Table View object to the ApplicationController class to specify its dataSource and delegate outlets.

        Right click on the Table View object to check the newly created associations for its dataSource and delegate outlets.

        • Step 05: Select the ApplicationController class and ctrl+drag to the Table View object to its tableView outlet.

        Right click on the ApplicationController class to check the newly create association for the tableView outlet.

        Using the Interface Builder, change the type for the tableView outlet to NSTableView.

        5. Create a button and link it to the application controller class’ update action

        • Step 01: Using the Interface Builder Library, click on the Objects tab and select the Views & Cells ⇒ Buttons folder.
        • Step 02: Drag and drop an NSButton from the library to the application window.

        Select the button and click on it once to rename it to Update.

        • Step 03: Select the Update button and ctrl+drag to the ApplicationController class in the Interface Builder NIB file browser.

        Right click on the ApplicationController class to check the newly create association for the update: action.

        6. Automatically generate source code and merge changes for the ApplicationController class

        • Step 01: Select the ApplicationController in the Interface Builder NIB file browser and click on File ⇒ Write Class Files.

        Browse to the folder: ~/Documents/Project/XCode/Tutorial/SingleColumnTableView
        Click on Save.
        Click on Merge. This will launch the FileMerge utility.

        • Step 02: Merge changes to the ApplicationController.h file.

        Select the ApplicationController.h file using the FileMerge utility.
        This will show the ApplicationController.h source code differences between the

        • a. new source code that we just automatically generated using Interface Builder, on the left hand side
        • b. previous source code that we had initially generated using Xcode, on the right hand side
        • Difference #1: Select the first difference by pressing the ↓ down arrow key. We want to keep the changes on the right side so, press the → right arrow key. Alternatively, you can use the Actions drop down list to choose the difference to be selected for inclusion in the final merge.
        • Difference#2: Select the difference on the left, since we don’t want the extra line break.
        • Difference#3: Select the difference on the left, since we want the IBOutlet NSTableView *tableView; entry to be included in the final merge.
        • Difference#4: Select the difference on the left, since we want the – (IBAction)update:(id)sender; entry to be included in the final merge.

        Save the merge by clicking on File ⇒ Save Merge. You should see a green tick mark next to the ApplicationController.h file.

        • Step 03: Merge changes to the ApplicationController.m file.

        Select the ApplicationController.m file using the FileMerge utility.

        This will show the ApplicationController.m source code differences between the

        • a. new source code that we just automatically generated using Interface Builder, on the left hand side
        • b. previous source code that we had initially generated using Xcode, on the right hand side
        • Difference #1: Select the difference on the right.
        • Difference#2: Select the difference on the left, since we don’t want the extra line break.
        • Difference#3: Select the difference on the left, since we want the – (IBAction)update:(id)sender; entry to be included in the final merge.

        Save the merge by clicking on File ⇒ Save Merge. You should see a green tick mark next to the ApplicationController.m file.

        Combine the files by selecting Merge ⇒ Combine Files.

        Open the ApplicationController.h file to view the merged changes.

        Open the ApplicationController.m file to view the merged changes.

        7. Add a data source for the table view

        • Step 01: Open the ApplicationController.h file and add a data source.

        Add the following lines of code just after the interface declaration:

        • // Data source
        • @private NSMutableArray *aBuffer;

        8. Implement NSTableView protocol methods for displaying table view contents

        • Step 01: Implement the protocol method to retrieve the total number of rows in a table view.

        Add the following lines of code to the ApplicationController.m file:

        • – (int)numberOfRowsInTableView:(NSTableView *)tableView{
        • return ([aBuffer count]);
        • }
        • Step 02: Implement the protocol method to retrieve the object value for a table column.

        Add the following lines of code to the ApplicationController.m file:

        • – (id)tableView:(NSTableView *)tableView
        • objectValueForTableColumn:(NSTableColumn *)tableColumn
        • row:(int)row{
        • return [aBuffer objectAtIndex:row];
        • }

        9. Implement the Update button handler

        • Step 01: Implement the ApplicationController update: method to print a log message to a console window and add a string object to the table view.

        Add the following lines of code to the update: method in the ApplicationController.m file:

        • – (IBAction)update:(id)sender {
        • NSLog(@”The user has clicked the update button”);
        • [aBuffer addObject:@”HelloWorld”];
        • [tableView reloadData];
        • }

        10. Implement the awakeFromNib and dealloc methods

        • Step 01: In the awakeFromNib method, implement code to create and allocate memory for a new mutable array object.

        Add the following lines of code to the ApplicationController.m file:

        • – (void)awakeFromNib{
        • aBuffer = [NSMutableArray new];
        • [tableView reloadData];
        • }
        • Step 02: In the dealloc method, implement code to release memory allocated to the mutable array object.

        Add the following lines of code to the ApplicationController.m file:

        • – (void)dealloc{
        • [aBuffer release];
        • [super dealloc];
        • }

        11. Build and run the application

        • Step 01: Display the Xcode console window by clicking on Run ⇒ Console.
        • Step 02: In the Xcode project window, click on the Build and Go icon to build and launch the application.
        • Step 03: Click on the Update button. This will create a row entry in the table view.

        View the resulting log messages on the console window.

        Document version: 1.0
        Document date: 2008-03-08
        Document reference: XCT_NSTVSC-1.0


        Development tools: Xcode 3.0, Interface Builder 3.0.
        Operating system: Mac OS X 10.5.2 (Leopard)

        Handling button events

        1. Create an Xcode project

        • Step 01: Launch Xcode 3.0 by clicking on the Xcode application icon.
        • Step 02: Click on File ⇒ New Project
        • Step 03: Select Application ⇒ Cocoa Application and click on the Next button.
        • Step 04: Specify the Project Name and Project Directory as follows:

        Project Name: HandlingButtonEvents
        Project Directory: ~/Documents/Project/XCode/Tutorial/HandlingButtonEvents/

        Click on the Finish button.

        This will bring up the Project window.

        2. Edit the NIB file

        • Step 01: In the Groups & Files browser, expand the NIB Files folder and double click the MainMenu.nib file

        This will launch the Interface Builder application.

        The Interface Builder (IB) application will display a set of windows for developing a Human Machine Interface (HMI):

        • a. Interface Builder NIB file browser
        • b. Interface Builder Inspector

        c. Interface Builder Library
        d. Application Main Menu window
        e. Application Window

        3. Create a controller class

        • Step 01: We will now use Xcode to create the application controller class. In the Groups & Files browser, right click on the Classes folder ⇒ Add ⇒ New File.
        • Step 02: Select Cocoa ⇒ Objective-C class and click on the Next button.

        Specify a name for the application controller class and click on the Finish button.

        Filename: ApplicationController.m

        You should now be able to see the files for the ApplicationController class will be automatically added to the Xcode project.
        Double click on the ApplicationController.h file to view its interface specifications.

        Double click on the ApplicationController.m file to view its implementation details.

        • Step 03: Click on the Interface Builder icon to bring it to the foreground. Using the Interface Builder Library, select Objects & Controllers ⇒ Controllers ⇒ NSObject and drag it to the Interface Builder NIB file browser.

        Using the Interface Builder Inspector, specify the following information:

        Class Identity ⇒ Class: ApplicationController
        Interface Builder Identify ⇒ Name: ApplicationController

        Because Interface Builder is automatically synchronized with Xcode, you can see the ApplicationController class that was previously created in Xcode, in the drop-down list box for the class identify.

        You should now be able to see the reference to the ApplicationController class in the NIB file browser as shown below.

        • Step 04: Specify an action that the application controller class can respond to.

        Click on the button and specify an action called update:

        Using Interface Builder, click on File ⇒ Write Class Files to to update the source files for the application controller class.

        Click on the Save button.

        Click on the Replace button to overwrite the existing application controller class files.

        Double click on the ApplicationController.h file from the Xcode project browser window.

        Observe the newly added action method entry in the interface file

        • – (IBAction)update:(id)sender;

        Double click on the ApplicationController.m file from the Xcode project browser window.

        Observe the newly added action method implementation entry in the implementation file

        • – (IBAction)update:(id)sender {
        • }
        • Step 05: Implement the update action method for the application controller class.

        As an example, add code to the ApplicationController.m implementation file to print a debug log message to a console window.

        • – (IBAction)update:(id)sender {
        • NSLog(@”The user has clicked the update button”);
        • }

        4. Create a button and link it to the application controller class’ update action

        • Step 01: Using the Interface Builder Library, click on the Objects tab and select the Views & Cells folder.
        • Step 02: Drag and drop an NSButton from the library to the application window.

        Select the button and click on it once to rename it to Update.

        • Step 03: Select the Update button and ctrl+drag to the ApplicationController class in the Interface Builder NIB file browser.

        Select the update: in the Recieved Actions pop-up window.

        Select the Update button and view the button connections using the Interface Builder Inspector.

        Select the ApplicationController class from the Interface Builder NIB file browser and view the application controller class connections.

        5. Build and run the application

        • Step 01: Display the Xcode console window by clicking on Run ⇒ Console

        This will bring up the Xcode console window.

        • Step 02: In the Xcode project window, click on the Build and Go icon to build and launch the application.

        This will launch the application window.

        • Step 03: Click on the Update button.

        View the resulting log messages on the console window.

        Base SDK Missing

        0
        0

        For the noobie iPhone App Developer, their reaction to the error message “Base SDK Mssing” on an xCode sample code project, is similar to how I once felt about the “Blue Screen of Death” on a PC.

        I got that same feeling of frustration when I loaded down the PageControl sample code from Apple. I couldn’t test the sample code in xCode because the “Base SDK Missing” error message was on display. I was using xCode 3.

        It wasn’t the first time I’d come across this error, however, previously I’d found a solution.  I was desperately seeking a solution to paging horizontally and having PageControl.

        I’ve solved my problems with the “Base SDK Missing” error message by trawling the internet and finding many generous people who share their knowledge.  So this “post” is me giving back to the app development community a little of what I’ve learned.

        Solving the “Base SDK Missing” Error

        Sometimes you will try to open an old xCode project and you will find you can’t open it because the file gives you a “Base SDK Missing” message, as shown in the image below:

         Base SDK Missing error message as seen on the xCode Dashboard

        The first time I came across this problem I was working through John Ray’s Book “iPad Application Development in 24 hours”. The problem raised its ugly head again when I tried to open the PageControl sample code from Apple.

        I came across the problem again when I found an article about sample code titled “How to Add A Slick iBooks Like Page Turning Effect Into Your Apps”, published by Johann “John” Dowa on his website ManiacDev. The article led me to a download for an xCode project called Leaves created by Tom Brow and an extension of the same project called “Leaves Two Pages” by Ole Begemann.

        I couldn’t open the projects because they gave an error message i.e. Base SDK Missing.  As mentioned, I’d had this message before but when I applied my solution, Solution 1, shock horror, it didn’t work.  So I hunted around the internet for more solutions and found Solution 2.  Both solutions are set out below:

        Solution One for xCode 3
        1) Select xCode File Name in the left side navigation bar and click on the blue Info button on the xCode Dashboard and a drop down menu will appear showing several tabs.

        Screenshot showing selection of xCode File Name

        xCode Dashboard Info Button
        xCode Dashboard

        2) Click on the Build Tab

        Info Button Drop Down List showing Build Tab

        3) Find “Base SDK” under Architecture section and select the appropriate version e.g. 4.2
        4) Scroll down to Deployment Section and also set “OS Deployment Target” as 4.2
        5) Close the xCode Project (do not close the xCode Program) then reopen the Project

        This solution came partly from a member of the iPhone SDK Development Forum and a little tweaking by me.

        If this did not fix the problem then follow the steps in solution two, as follows:
        Sometimes, if the test file has been created in a very old xCode Program,  you need to take more steps.
        A solution for this problem was solved by a member of the “Leaves Developers” Google Group.

        Solution Two
        1) In xCode go to Targets and right click over the file name and select “Get Info”

        Target Get Info Drop Down Menu

        2) A drop down list will appear. Go to the Architecture section and click on the Base SDK Value field and select the correct iOS.

        Target Architecture Drop Down Menu

        3) Close the xCode Project (do not close the x Code program) and reopen the project.  Hopefully you will then see that the Base SDK Missing message has disappeared and you are seeing “Simulator …

        Simulator Button on the xCode Dashboard

        WebKit Open Source Project

        0
        0

        Here are some demo web applications that display various web technologies supported by WebKit.

        Offline Calendar
        Picking up where the sticky notes example leaves off, the Offline Calendar demo goes much more in depth into the power of the HTML 5 database API.
        By storing the user’s calendar events in a local databases and caching the application resources themselves using the HTML 5 application cache the calendar can be used with no network connection!

        CSS Transitions and Transforms
        This demo shows off how straight forward it is to add transforms and implicit animations to a web application by adding a small amount of CSS.
        Check out our blog posts about CSS animations and CSS transforms for more details and examples.

        Editing Toolbar
        The editing toolbar shows off a rich HTML editing toolbar in WebKit. It uses JavaScript and CSS to fade in and out and to implement the buttons that apply text formatting and alignment. Click in the text area to see the toolbar appear.

        Sticky Notes
        Referenced about adding HTML 5 structured database storage, this is a simple example of how the database API works in the form of persistent yellow sticky notes.
        Storing simple data, it is a great way for developers to introduce themselves to how the database API works.

        Ray Wenderlich Tutorials

        0
        0

         

        Beginning iPhone Programming

        iPhone programming is like a ladybug – fun and only a little scary!
        If you’re completely new to iPhone programming, start here! First there’s a tutorial series that will walk you through the process of creating an iPhone app from start to finish – using the most common APIs that almost every app uses. Next there’s a tutorial about memory management – the area where beginners most often get confused about!
        Also, if you’re a beginner you should sign up for our monthly iOS newsletter – to thank you for signing up, we’ll give you a free copy of the 1st tutorial in the iOS Apprentice series! This is an epic-length tutorial for complete beginners that walks you through creating your first app, and it’s fully updated for iOS 5.

        How To Create a Simple iPhone App on iOS 5 Tutorial: 1/3
        How To Create a Simple iPhone App on iOS 5 Tutorial: 2/3
        How To Create a Simple iPhone App on iOS 5 Tutorial: 3/3
        My App Crashed – Now What? 1/2
        My App Crashed – Now What? 2/2
        Objective-C Cheat Sheet and Quick Reference
        iOS for High School Students: Getting Started
        iOS For High School Students: Text Adventure Game
        Memory Management in Objective-C Tutorial
        How To Debug Memory Leaks with XCode and Instruments Tutorial
        Using Properties in Objective-C Tutorial
        How to Submit Your App to Apple: From No Account to App Store, Part 1
        How to Submit Your App to Apple: From No Account to App Store, Part 2

         

        iOS 5 Tutorials

        Want some iOS 5 Tutorials? We got you covered!
        iOS 5 is one of the biggest updates to iOS so far. It has tons of cool new APIs and features you can use in your apps, from ARC to Storyboards to iCloud to GLKit to much more! We wrote a huge book called iOS 5 By Tutorials that covers everything you need to know, and we’re also releasing some of the chapters here for free!

        Introducing the iOS 5 Feast
        User Interface Customization in iOS 5
        Beginning Storyboards in iOS 5 Part 1
        Beginning Storyboards in iOS 5 Part 2
        Beginning Turn-Based Gaming with iOS 5 Part 1
        Beginning Turn-Based Gaming with iOS 5 Part 2
        Working with JSON in iOS 5
        Beginning iCloud in iOS 5 Tutorial Part 1
        Beginning iCloud in iOS 5 Tutorial Part 2
        Beginning Twitter in iOS 5
        Beginning ARC in iOS 5 Part 1
        Beginning ARC in iOS 5 Part 2
        Beginning Core Image in iOS 5
        UIKit Particle Systems in iOS 5
        UIGestureRecognizer Tutorial in iOS 5: Pinches, Pans, and More!
        Basic Security in iOS 5 Tutorial Part 1
        Basic Security in iOS 5 Tutorial Part 2
        How To Create a PDF with Quartz2D in iOS 5 Tutorial Part 1
        How To Create a PDF with Quartz2D in iOS 5 Tutorial Part 2
        How To Use Blocks in iOS 5 Tutorial Part 1
        How To Use Blocks in iOS 5 Tutorial Part 2
        How To Create a Rotating Wheel Control with UIKit
        How To Use UIScrollView to Scroll and Zoom Content

         

        Beginning Game Programming with Cocos2D

        Ninjas Going Pew-Pew!
        If you want to make games on the iPhone, the easiest way by far is to use the Cocos2D iPhone framework! These tutorials will help get you started by showing you how to make some simple games and solve common problems.
        In addition to these tutorials, you might be interested in the Cocos2D book by Rod Strougo and myself.

        How To Make A Simple iPhone Game with Cocos2D
        Rotating Turrets: How To Make A Simple iPhone Game with Cocos2D Part 2
        Harder Monsters and More Levels: How To Make A Simple iPhone Game with Cocos2D Part 3
        How To Make a Tile Based Game with Cocos2D
        Collisions and Collectables: How To Make a Tile Based Game with Cocos2D Part 2
        How To Use Animations and Sprite Sheets in Cocos2D
        How To Make a Space Shooter iPhone Game
        How To Create a HUD Layer with Cocos2D

         

        Intermediate Game Programming with Cocos2D

        Whack this Mole!
        If you’ve finished the Beginning Game Programming tutorials and are itching for some more, check out these tutorials for more advanced techniques!

        How To Create Buttons in Cocos2D: Simple, Radio, and Toggle
        How To Drag and Drop Sprites with Cocos2D
        How To Create A Mole Whacking Game With Cocos2D: Part 1/2
        How To Create A Mole Whacking Game With Cocos2D: Part 2/2
        Introduction to Augmented Reality on the iPhone
        How To Create Dynamic Textures with CCRenderTexture
        How To Create A Game Like Tiny Wings Part 1
        How To Create A Game Like Tiny Wings Part 2
        How To Mask a Sprite with Cocos2D 1.0
        How To Mask a Sprite with Cocos2D 2.0
        How To Integrate Cocos2D and UIKit
        How To Create a Multi-Directional Scrolling Shooter Part 1
        How To Create a Multi-Directional Scrolling Shooter Part 2
        Introduction to A* Pathfinding
        How To Implement A* Pathfinding with Cocos2D

         

        Cocos2D Tools

        Create this game with some great Cocos2D tools!
        There are some great tools available that make your job as a Cocos2D developer much easier. Check out these tutorials to learn about the tools and how to use them effectively!

        How To Create and Optimize Sprite Sheets in Cocos2D with Texture Packer and Pixel Formats
        How To Build a Monkey Jump Game Using Cocos2D, PhysicsEditor & TexturePacker Part 1
        How To Build a Monkey Jump Game Using Cocos2D, PhysicsEditor & TexturePacker Part 2
        How To Build a Monkey Jump Game Using Cocos2D, PhysicsEditor & TexturePacker Part 3
        How To Use SpriteHelper and LevelHelper Tutorial
        How to Make a Game Like Jetpack Joyride using LevelHelper and SpriteHelper [Cocos2D Edition] – Part 1
        How to Make a Game Like Jetpack Joyride using LevelHelper and SpriteHelper [Cocos2D Edition] – Part 2
        How to Make a Game Like Jetpack Joyride using LevelHelper and SpriteHelper [Cocos2D Edition] – Part 3
        How to Make a Game Like Jetpack Joyride using LevelHelper and SpriteHelper [Cocos2D Edition] – Part 4
        Adding iCade Support to Your Game

         

        Advanced Game Programming with OpenGL

        The lowest level game programming API available on iOS is OpenGL ES 2.0. It gives you the most power and flexibility, but has a notoriously high learning curve. That’s where this site comes to the rescue – we try to explain it as simply as possible and get you started with some simple examples!

        Learn how to make games the hardcore way!

        OpenGL ES 2.0 for iPhone Tutorial
        OpenGL ES 2.0 for iPhone Tutorial Part 2: Textures
        Beginning OpenGL ES 2.0 with GLKit Part 1
        Beginning OpenGL ES 2.0 with GLKit Part 2
        How To Create A Simple 2D iPhone Game with OpenGL ES 2.0 and GLKit Part 1
        How To Create A Simple 2D iPhone Game with OpenGL ES 2.0 and GLKit Part 2
        How To Create Cool Effects with Custom Shaders in OpenGL ES 2.0 and Cocos2D 2.X

         

        Other Game Engines

        Learn about Corona, Unity3D, and more!
        Other than Cocos2D and OpenGL, there are a lot of other great game frameworks available on iOS. If you want to play around with some of them as well, check out these tutorials!

        How To Make a Game Like Doodle Jump with Corona Tutorial Part 1
        How To Make a Game Like Doodle Jump with Corona Tutorial Part 2
        How to Make a Game Like Jetpack Joyride using LevelHelper and SpriteHelper [Corona Edition] – Part 1
        How to Make a Game Like Jetpack Joyride using LevelHelper and SpriteHelper [Corona Edition] – Part 2
        How to Make a Game Like Jetpack Joyride using LevelHelper and SpriteHelper [Corona Edition] – Part 3
        How to Make a Game Like Jetpack Joyride using LevelHelper and SpriteHelper [Corona Edition] – Part 4
        How To Make a 2.5D Game With Unity Tutorial: Part 1
        How To Make a 2.5D Game With Unity Tutorial: Part 2
        How To Make a Simple iPhone Game with Flash CS5

         

        Game Physics

        Create a simple game with Chipmunk physics!
        It turns out there are some great libraries available out there that you can use to easily add physics to your games – without having to be a math expert! These tutorials will show you how to get started with these libraries so you can use them to create amazing effects in your games!

        Intro to Box2D with Cocos2D Tutorial
        How To Create a Simple Breakout Game with Box2D and Cocos2D Tutorial: Part 1/2
        How To Create a Simple Breakout Game with Box2D and Cocos2D Tutorial: Part 2/2
        How To Use Box2D for Just Collision Detection
        How To Create A Simple iPhone Game with Chipmunk Physics Tutorial
        Intermediate Box2D: Physics, Forces, Ray Casts, and Sensors
        How To Make a Catapult Shooting Game with Cocos2D and Box2D Part 1
        How To Make a Catapult Shooting Game with Cocos2D and Box2D Part 2

         

        Other Game Programming Topics

        Tomato-San says: w00t, it’s done!
        While we’re on the topic of game programming, here are a few posts with some tips and tricks for game developers.

        Game Analytics 101
        5 Things I Learned Making My First iPhone Game
        How To Generate Game Tiles with Python Imaging Library
        How To Host a Beta Test for your iPhone App
        A n00bs Guide to Making a Beta Signup Form with PHP and WordPress
        Introducing VickiWenderlich.com: Free Art and Artist Tutorials

         

        Saving and Loading Data

        Core Data Failed Banks Model Diagram
        Almost every app needs to save and load data on the iPhone – and there are many different ways to do so. In these tutorials, you can get hands-on experience with many of the most common methods.

        How To Choose the Best XML Parser for your iPhone Project
        How to Read and Write XML Documents with GDataXML
        SQLite 101 for iPhone Developers: Creating and Scripting
        SQLite 101 for iPhone Developers: Making Our App
        Core Data on iOS 5 Tutorial: Getting Started
        Core Data on iOS 5 Tutorial: How To Preload and Import Existing Data
        Core Data Tutorial: How To Preload and Import Existing Data (pre iOS 5 version)
        Core Data on iOS 5 Tutorial: How to use NSFetchedResultsController
        How to Save Your App Data with NSCoding and NSFileManager
        How to Integrate iTunes File Sharing with your iOS App
        How to Import and Export App Data via Email in your iOS App

         

        Graphics and Animation

        Welcome to Core Graphics 101!
        In order to be successful on the App Store these days, your app needs to look good. Here are a few tutorials that you can use to up the quality level of your apps, and your gain mad skills with graphics and animation programming.

        Core Graphics 101: Lines, Rectangles, and Gradients
        Core Graphics 101: Shadows and Gloss
        Core Graphics 101: Arcs and Paths
        Core Graphics 101: Glossy Buttons
        Core Graphics 101: Patterns
        How to use UIView Animation Tutorial
        UIView Animation Tutorial: Practical Recipes
        Introduction to CALayers Tutorial
        How to Write a Custom Image Picker like UIImagePicker
        How to Make a Custom UIView: a 5-star Rating View
        Beautiful Table View Helper Class
        How To Create a Simple Magazine App with Core Text

         

        Network Programming

        Web Services + iPhone Apps Rule!
        You can take your app to the next level by integrating with a server-back end or allowing networking between devices. These tutorials show you how!

        How To Make a Simple Multiplayer Game with Game Center Tutorial: Part 1/2
        How To Make a Simple Multiplayer Game with Game Center Tutorial: Part 2/2
        Apple Push Notification Services Tutorial: Part 1/2
        Apple Push Notification Services Tutorial: Part 2/2
        How To Write A Simple PHP/MySQL Web Service for an iOS App
        How To Write An iOS App That Uses A Web Service
        How To Create A Socket Based iPhone App and Server
        How To Make a Multiplayer iPhone Game Hosted on your Own Server Part 1
        How To Make a Multiplayer iPhone Game Hosted on your Own Server Part 2

         

        Making Money

        1) Integrate iAd 2) ??? 3) PROFIT!
        There are certain technologies and techniques you can use in your apps that can directly help you make ‘mo money! And although money can’t buy happiness, you gotta pay for your beer somehow amirite?

        Introduction to In-App Purchases
        How To Integrate iAd into Your iPhone App
        How To Localize an iPhone App Tutorial
        How To Integrate AdWhirl into a Cocos2D Game
        How To Market and Promote Your Games and Apps Part 1/4
        How To Market and Promote Your Games and Apps Part 2/4
        How To Market and Promote Your Games and Apps Part 3/4
        How To Market and Promote Your Games and Apps Part 4/4

         

        Audio

        Screenshot from BasicSounds sample project
        When I first started iOS programming, I knew a WAV file played sounds and that was about it. These posts explain a lot about audio files and formats, and explain how you can play audio in your apps.

        Audio 101 for iPhone Developers: File and Data Formats
        Audio 101 for iPhone Developers: Converting and Recording
        Audio 101 for iPhone Developers: Playing Audio Programatically

         

        iPad Development

        What it will look like when we’re done!
        If you know how to program for the iPhone, it’s a simple matter to program for the iPad as well! These tutorials walk you through some of the differences and help get you started with some of the new APIs available on the iPad.

        iPad for iPhone Developers 101: UISplitView Tutorial
        iPad for iPhone Developers 101: UIPopoverController Tutorial
        iPad for iPhone Developers 101: Custom Input View Tutorial
        How to Port an iPhone Application to the iPad

         

        3rd Party Libraries

        There are a lot of third party APIs and SDKs you might want to include in your apps. These tutorials cover a few of them and show you how to get started.

        How to Post on Facebook with your iPhone App
        Hot to Use Facebook’s New Graph API from your iPhone App
        How to Get a User Profile with Facebook’s New Graph API
        How to Post to a User’s Wall, Upload Photos, and Add a Like Button from your iPhone App
        Introduction to Three20
        How to Use the Three20 Photo Viewer
        How to Translate Text with Google Translate and JSON on the iPhone
        How To Make A Simple RSS Reader iPhone App Tutorial
        Unit Testing in Xcode 4 Quick Start Guide

         

        Other iPhone Tutorials

        Plot Baltimore crime data using MapKit!
        There’s always something that doesn’t fit anywhere else! Here’s a hodgepodge of other posts and tutorials you may find interesting. Multithreading and Grand Central Dispatch on iOS for Beginners Tutorial

        How To Make An Interface with Horizontal Tables Like The Pulse News App Part 1
        How To Make An Interface with Horizontal Tables Like The Pulse News App Part 2
        Introduction to MapKit on iOS Tutorial
        iOS Code Signing: Under The Hood
        How to Autocomplete with Custom Values

         

        Android tutorials

        Get started with Android development!
        This site has just started expanding with some Android tutorials as well. If you’re completely new to developing for Android, these tutorials are a great way to get started!

        Getting Started with Android Development
        Getting Started with Android Development – Part 2

         

        Training, Announcements, and Notes

        One day class introducing iOS programming for beginners!
        From time to time I announce upcoming training, books, and other types of announcements from this site. Here’s the news so far!

        Web Design: Drinking from a Firehose
        What is this Blog About?
        The iPad SDK and NDA
        My Favorite Mac Applications
        How to Move Your WordPress Blog to Linode
        Introducing Tom the Turret Cocos2D Sample Game
        Upcoming Class: iOS Programming 101
        Cocos2D Book and 360iDev
        iPhone 101 for Baltimore Developers
        Beginner iPhone Class Available
        Upcoming Workshop: Cocos2D via Minigames
        Why I’m Ditching iOS and Becoming An Android Developer (April Fools Joke!)
        Cocos2D Book Giveaway (prerelease)
        Cocos2D Book Giveaway Winner (prerelease)
        Looking For Tutorial Writers
        June Workshop: Cocos2D via Minigames
        Cocos2D via Minigames Workshop Update
        Space Game Starter Kit Update
        Learning Cocos2D Book Giveaway (post release)
        Learning Cocos2D Book Giveaway Winners! (post release)
        Space Game Starter Kit Now Available!
        Upcoming Talks and Workshops
        Looking for More Tutorial Writers
        Reminder: Upcoming Cocos2D via Minigames Workshops
        An iOS 5 Surprise Coming Soon!
        iOS Apprentice Complete Series Giveaway
        iOS 5 By Tutorials Update Now Available
        iOS Apprentice Early Bird Discount Ending Soon
        iOS 5 Feast Giveaway Results
        The raywenderlich.com Team
        iOS 5 By Tutorials Final Chapters Now Available
        Merry Christmas 2011
        iOS Marketing Survey
        iOS Apprentice Tutorial 4 Now For Sale!
        Simple iOS App Tutorial Updated for iOS 5
        Jetpack Joyride Tutorial Ported to Corona
        iOS 5 By Tutorials Complete!
        Reader’s Apps Reviews – March 2012
        MapKit Tutorial Updated for iOS 5
        Thermometer App Starter Kit Now Available (April Fools Joke!)
        Reader’s Apps Reviews – April 2012
        Core Data Tutorial Series Updated for iOS 5

        Unity Game Development

        0
        0

        Unity 3 is a game development tool that has been designed to let you focus on creating amazing games. If you’ve tried Unity before, see whats new in 3.0. If this is your first time, take a look around or try Unity for yourself.

        Free Full Version for OS X with Unity Pro, Android and iOS trials.

        ↓ Download Unity 3.3

        System Requirements

        System Requirements for Unity Authoring

        • Windows: XP SP2 or later; Mac OS X: Intel CPU & “Leopard” 10.5 or later. Note that Unity was not tested on server versions of Windows and OS X.
        • Graphics card with 64 MB of VRAM and pixel shaders or 4 texture units. Any card made in this millennium should work.
        • Using Occlusion Culling requires GPU with Occlusion Query support (some Intel GPUs do not support that).
        • The rest only depends on the complexity of your projects!.

        System Requirements for Unity iOS Authoring

        • An Intel-based Mac
        • Mac OS X “Snow Leopard” 10.6 or later
        • The rest only depends on the complexity of your projects!

        System Requirements for Unity Android Authoring

        • In addition to the general system requirements for Unity Authoring
        • Windows XP SP2 or later; Mac OS 10.5.8 or later
        • Android SDK and Java Development Kit (JDK)

        System Requirements for Unity-Authored Content

        • Windows 2000 or later; Mac OS X 10.4 or later.
        • Pretty much any 3D graphics card, depending on complexity.
        • Online games run on all browsers, including IE, Firefox, Safari, and Chrome, among others.
        • Android authored content requires devices equipped with:
        • Android OS 2.0 or later
        • Device powered by an ARMv7  (Cortex family) CPU
        • GPU support for OpenGLES 2.0 is recommended

        Unity Widgets

        Building
        Besides regular Mac apps, Unity can build MacOSX widgets, using the Unity web plugin.

        Customization

        The widgets are just a web player wrapped with the widget HTML. If you right/option-click on the .wdgt file and select Show Package, you’ll see the generated Unity file and accompanying HTML, CSS and images. Any additional files loaded by the widget can be added in the widget. For example, this widget streams a movie, cat.ogv.
        You will probably want to customize the default Unity build by replacing the Icon.png file, which is the icon that displays in the Dashboard dock. Version information can be adjusted in the Info.plist file. You can customize the back panel by modifying the HTML and CSS files.

        Publishing
        Most widgets are submitted and listed on the Apple widget download page. Most widgets are free, though some are listed as shareware. If a widget is listed as a Staff Favorite or Featured Widget, it certainly ends up in the Top 50.

        Widgets published include HyperBowl Classic, FuguBowl, FuguMaze, FuguTilt, FuguFlip, Fugutype…
        Other Unity widgets include 3D Paradise Paintball, MacPinball, Banana Warehouse and Blingy.

        References
        See the Apple Dashboard developer article for an overview of widget and links to more articles.

        Creating an Interactive iPhone App

        0
        0

        Creating the New Project
        The purpose of the application we are going to create is to perform unit conversions from Fahrenheit to Centigrade. Obviously the first step is to create a new Xcode project to contain our application.
        Start Xcode and on the Welcome screen select Create a new Xcode project. On the template screen choose the Application option located under iOS in the left hand panel and select View-based Application. Click Next, name the product UnitConverter, enter your company identifier and make sure that the Product menu is set to iPhone. On the final screen, choose a location in which to store the project files and click on Create to proceed to the main Xcode project window.
         
        Creating the User Interface
        Before we begin developing the logic for our interactive application we are going to start by designing the user interface. When we created the new project, Xcode generated an Interface Builder NIB file for us and named it UnitConverterViewController.xib. It is within this file that we will create our user interface, so select this file from the project navigator in the left hand panel to load it into Interface Builder. Once Interface Builder has loaded the file select the far right of the three View buttons in the Xcode toolbar to display the right hand panel. In the lower panel, select the Show the Object library toolbar button (the black 3D cube) to display the UI components. Alternatively, simply select the View -> Utilities ->

        Object Library menu option:

        From the Object Library panel View -> Utilities -> Object Library, drag a Text Field object onto the View design area. Resize the object and position it so that it appears as follows:

        Within the Attribute Inspector panel View -> Utilities -> Attribute Inspector, type the words Enter temperature into the Placeholder text field. This text will then appear in a light gray color in the text field as a visual cue to the user.
        Now that we have created the text field for the user to enter the temperature into, the next step is to add a Button object that can be pressed to initiate the conversion. To achieve this drag and drop a Rounded Rect Button object from the Library to the View. Double click the button object so that it changes to text edit mode and type the word Convert onto the button. Finally, select the button and drag it beneath the text field until the blue dotted line appears indicating it is centered vertically in relation to the text field before releasing the mouse button.
        The last user interface object we need to add is a label where the result of the conversion will be displayed. Add this by dragging a Label object from the Library window to the View and position it beneath the button. Stretch the width of the label so that it is approximately a third of the overall width of the view and reposition it using the blue guidelines to ensure it is centered in relation to the button.
        Double click on the label to highlight the text and press the backspace key to clear the text (we will set the text from within a method of our View Controller class when the conversion calculation has been performed). Though the label is now no longer visible it is still present in the view. If you click where it is located it will be highlighted with the resize dots. At this point the user interface design phase of our project is complete and the view should appear as illustrated in the following figure. We now are ready to try out a test build and run.

        Building and Running the Sample Application
        Before we move on to writing the controller code for our application and then connecting it to the user interface we have designed we should first perform a test build and run of the application so far. Click on the Run button located in the toolbar to compile the application and run it in the simulator. If you are not happy with the way your interface looks feel free to reload it into Interface Builder and make improvements. Assuming the user interface appears to your satisfaction in the simulator we are ready to start writing some Objective-C code to add some logic to our controller. Exit from the simulator before proceeding to the next step by selecting the iOS Simulator -> Quit iOS Simulator menu option.

        Adding Actions and Outlets
        When the user enters a temperature value into the text field and touches the convert button we need to trigger an action that will perform a calculation to convert the temperature. The result of that calculation will then be presented to the user on the label object. The Action will be in the form of a method that we will declare and implement in our View Controller class. Access to the text field and label objects from the view controller method will be implemented through the use of Outlets.

        The UIKit framework contains a class called UIViewController that provides the basic foundation for adding view controllers to an application. In order to create a functional application, however, we inevitably need to add functionality specific to our application to this generic view controller class. This is achieved by subclassing the UIViewController class and extending it with the additional functionality we need.

        When we created our new project, Xcode anticipated our needs and automatically created a subclass of UIViewController and named it UnitConverterViewController (using as a prefix the name that we gave to our new project). In so doing, Xcode also created two source files; a header file named UnitConverterViewController.h and a source code file named UnitConverterViewController.m.
        Selecting the UnitConverterViewController.h file in the Xcode project navigator panel will display the contents of the file in the editing pane:

        //
        // UnitConverterViewController.h
        // UnitConverter
        //
        // Created by Techotopia on 1/10/11.
        // Copyright __MyCompanyName__ 2011. All rights reserved.
        //
        #import

        @interface UnitConverterViewController : UIViewController {
        }
        @end


        As we can see from the above code, a new class called UnitConverterViewController has been created that is a subclass of the UIViewController class belonging to the UIKit framework.
        The next step is to extend the subclass to include the two outlets and our action method. We will begin by adding outlets for our text field and label objects by declaring variables and using the IBOutlet keyword:


        #import

        @interface UnitConverterViewController : UIViewController {
        UITextField *tempText;
        UILabel *resultLabel;
        }
        @property (nonatomic, retain) IBOutlet UILabel *resultLabel;
        @property (nonatomic, retain) IBOutlet UITextField *tempText;
        @end
        Next we need to declare the action that will be called when the user touches the Convert button in our user interface. This is declared using the IBAction keyword:
        #import

        @interface UnitConverterViewController : UIViewController {

        UITextField *tempText;
        UILabel *resultLabel;
        }
        @property (nonatomic, retain) IBOutlet UILabel *resultLabel;
        @property (nonatomic, retain) IBOutlet UITextField *tempText;
        – (IBAction)convertTemp:(id)sender;
        @end

        We have now declared that our View Controller class contains a method called convertTemp. Having made that declaration, we need to implement the method in the implementation source file. To do so, select the UnitConverterViewController.m file so that the contents appear in the editing pane:


        #import “UnitConverterViewController.h”

        @implementation UnitConverterViewController


        /*

        // The designated initializer. Override to perform setup that is required before the view is loaded.
        – (id)initWithNibName:(NSString *)
        nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
        if (self = [super initWithNibName:nibNameOrNil
        bundle:nibBundleOrNil]) {
        // Custom initialization
        }
        return self;
        }
        */
        /*
        // Implement loadView to create a view hierarchy programmatically, without using a nib.
        – (void)loadView {
        }
        */
        /*
        // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
        – (void)viewDidLoad {
        [super viewDidLoad];
        }
        */
        /*
        // Override to allow orientations other than the default portrait orientation.
        – (BOOL)shouldAutorotateToInterfaceOrientation:
        (UIInterfaceOrientation)interfaceOrientation {
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
        }
        */
        – (void)didReceiveMemoryWarning {
        // Releases the view if it doesn’t have a superview.
        [super didReceiveMemoryWarning];

        // Release any cached data, images, etc that aren’t in use.

        }
        – (void)viewDidUnload {
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
        }
        – (void)dealloc {
        [super dealloc];
        }
        @end


        The first step is to instruct Objective-C to synthesize accessor methods for our tempText and resultLabel objects and then to implement the convertTemp method. The relevant section of the UnitConverterViewController.m file should now read as follows:


        #import “UnitConverterViewController.h”

        @implementation UnitConverterViewController
        @synthesize resultLabel, tempText;

        – (void) convertTemp: (id) sender {
        double farenheit = [tempText.text doubleValue];
        double celsius = (farenheit – 32) / 1.8;

        NSString *resultString = [[NSString alloc]
        initWithFormat: @”Celsius %f”, celsius];
        resultLabel.text = resultString;
        [resultString release];
        }
        .
        .
        .
        @end


        Before we proceed it is probably a good idea to pause and explain what is happening in the above code. Those already familiar with Objective-C, however, may skip the next few paragraphs.
        In this file we are implementing the convertTemp method that we declared in the .h file. This method takes as a single argument a reference to the sender. The sender is the object that triggered the call to the method (in this case our Button object). Whilst we won’t be using this object in the current example, this can be used to create a general purpose method in which the behavior of the method changes depending on how (i.e. via which object) it was called. We could, for example, create two buttons labeled Convert to Fahrenheit and Convert to Celsius respectively, each of which calls the same convertTemp method. The method would then access the sender object to identify which button triggered the event and perform the corresponding type of unit conversion. 

        Next, the code declares a variable of type double in order to handle the fact that the user may have entered a floating point value. We then use dot notation to access the text property (which holds the text displayed in the text field) of the UITextField object. This property is itself an object of type NSString. The NSString class has an instance method named doubleValue that converts the string value to a double. We therefore call this method on the text property and assign the result to our farenheit variable.
        Having extracted the text entered by the user and converted it to a number we then perform the conversion to Celsius and store the result in another variable named celsius. Next, we create a new NSString object and initialize it with text that comprise the word Celsius and the result of our conversion. In doing so, we declare a pointer to this new object and call it resultText.


        Finally, we use dot notation to assign the new string to the text property of our UILabel object so that it is displayed the user. The last step releases the memory that was allocated to the object referenced by resultText since it is no longer needed. Having created our action method we also need to modify the viewDidUnload and dealloc methods in this file to make sure we properly release the memory we allocated for our variables. Failure to do so will result in a memory leak in our application:


        – (void)viewDidUnload {
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
        self.resultLabel = nil;
        self.tempText = nil;
        }
        – (void)dealloc {
        [resultLabel release];
        [tempText release];
        [super dealloc];
        }


        Before proceeding to the next section of this chapter, now is a good time to perform a build and run to make sure that no errors exist in the code. Click on the Run button in the toolbar and correct any syntax errors that are reported.


        Connecting the Actions and Outlets to the User Interface
        The final step in developing our application is to connect the actions and outlets we have declared in the view controller class to the actual objects in the user interface view. Fortunately, this can all be done visually from within the Interface Builder tool.
        With this in mind, select the UnitViewController.xib file to load the user interface into Interface Builder. We will begin by connecting the IBOutlet instance variables we created in our view controller class to the label and text field objects respectively. Located in the narrow panel to the left of the graphical view of the user interface are three icons. Clicking on the small square with the black triangle at the bottom of this panel will expand the panel to provide more detail:

         The top icon is the File’s Owner. This icon represents the file containing the class that invokes the user interface contained in the NIB file when the application runs. In this instance it is the UnitConverterViewController class, where we declared our actions and outlets.

        To connect the resultLabel IBOutlet variable to the label object, hold down the Control key on the keyboard, click on the File’s Owner icon and drag the mouse to the location of the label object in the user interface design. A blue line will extend from the icon to the object as illustrated in the following figure:

        Upon releasing the mouse button, Interface Builder will display a list of IBOutlet variables that match the type of the object selected:

        Select resultLabel from the menu to complete the connection. Repeat these steps to connect the tempText outlet to the text field object. In order to view the connections you have created, display the Connections Inspector by selecting the far right hand toolbar option in the top section of the right hand panel or selecting View -> Utilities -> Connections Inspector. For example, the following figure shows the connection information for our label object:

        The final step is to connect the button object to our convertTemp action method. Cocoa Touch objects typically have a wide range of events that can be triggered by the user. To obtain a full listing of the events available on a particular object, display the Connections Inspector View -> Utilities -> Connections Inspector and select the button object in the view window. Listed under Sent Events in the connections panel is a list of the events that can be triggered by the button object. In this instance, we are interested in the Touch Up Inside event. This event is triggered when a user touches the button and then releases their finger without first sliding it outside the boundaries of the button. When this action is performed we want our convertTemp method to be called. To make this connection, move the mouse pointer to the small circle next to the Touch Up Inside event in the connections panel, click the mouse button and drag to the File’s Owner icon as illustrated in the following figure:

        Releasing the mouse button over the File’s Owner icon will display a menu with a list of methods available in the view controller class. In our case the only method is convertTemp so select that method to initiate the connection. The event listing in the Connections dialog will subsequently update to reflect the new connection.
         

        Building and Running the Finished Application
        From within the Xcode project window click on Run to compile the application and run it in the simulator. Once the application is running, click inside the text field and enter a Fahrenheit temperature. Next, click on the Convert button to display the equivalent temperature in Celsius. Assuming all went to plan your application should appear as outlined in the following figure (note that if the keyboard obscures the result label you will need to reload the user interface design into Interface Builder and move the label, button and text field objects so that they are all positioned in the top half of the view):


        Moving from Xcode 3 to Xcode 4

        0
        0

        The majority of changes that will affect you for Xcode 4 are related to a redesigned user interface. This post offers a general overview of these differences, including hidden panels and integrated Interface Builder.

        Overall Interface Redesign
        Perhaps the most obvious change is that everything is now unified into a single-window interface.

        When you first open a project in Xcode 4 (or create a new one), you’ll notice a lack of items in the lefthand portion (which under Xcode 3 would be the Groups & Files list). For the TextApp project from the first chapter of the book, you’ll find only a single item listed, with an Xcode project icon:

        Expand this to see the files within it, and click a file to open it in the editor:

        Because Xcode 4 is designed primarily so that everything occurs within a single window (it is still possible to double-click a file to open it in a separate window), many features are “hidden” behind panels and navigator controls.

        The left portion of the main window contains Navigators, each of which is used to navigate through different aspects of a project—use the little icon buttons to choose which one. Since you’ll find yourself swapping between navigators fairly frequently, it’s worth pointing out that the icons correspond to the options in the View > Navigators menu, so each has a prominent keyboard shortcut.

        If you’re relatively new to coding, or even just to Xcode, it’s easy to become confused as to why you’re not seeing what you think you should be seeing in this navigator pane. To see the list of groups and files, you need the Project Navigator (Cmd-1).

        Debugger Console
        The Debugger Console (a separate window under Xcode 3) has also been moved into the main interface, and the default keyboard shortcut has changed. You’ll need to use the segmented control labelled View in the main toolbar of the Xcode window to display the “bottom bar.”

        This lower panel is known as the Debug Area in Xcode 4, and can also be hidden/shown from the View menu (Shift-Cmd-Y). The Debug Area has several purposes; it’s also used instead of another, separate Debugger window in Xcode 3. Depending on which you need (it’s the Console area on the right for this book), you can choose whether to show both panels or just one using the segmented control that appears in the lower panel of the window:

        The default behavior in Xcode 4 is to hide the debug area each time you run an application. If you wish, you can change this—choose Xcode > Preferences… (Cmd-,) and select the Behaviors tab, then set what happens when a Run starts to Show the Debug Area automatically each time:

        Note that if you’re particularly attached to any default Xcode 3 keyboard shortcuts, it’s possible to change the Xcode 4 shortcuts using the Key Bindings tab in the Preferences window.

        Separate Windows
        If you don’t like having everything arranged on the one window, Xcode 4 can open as many extra windows as you like. Double-clicking any file, for example, will open that file in a new window. Working with multiple windows can get confusing, though, particularly when it comes to closing the project. Skip this section if you’re still relatively new to Xcode in any version.

        Once you have a new window open, you decide how much you want it to display. If you particularly want a separate debugger console window, for example, choose File > New > New Window (Shift-Cmd-T). By default, a new window opened in this way will display the same information as the previous front-most window. If this is the first new window you’ve opened for a project, you’ll effectively get two identical Xcode project windows. Use the new window’s main toolbar to turn off the left and right bars, and display the bottom bar, then drag the bottom bar up to fill the window:

        Once you’ve done that, you can hide the main toolbar itself by clicking the button in the top right of the window’s title bar:

        Xcode 4 will remember the window locations and layout when you close the project, but make sure you use File > Close Project to do so (by default this doesn’t have a keyboard shortcut, but you can add one in the Preferences window—in the Key Bindings panel, the command is listed as Close Workspace).

        If you instead try to close the project by closing what looks to you like the main project window, the project will still be open, but with only the shrunk console window on display. If you then close this window as well (at which point Xcode will close the project because that’s the last open window), then all you’ll see when you next open the project will be the console window. The first time this happened to me, I had a minor panic trying to figure out how to get back to my original window. If this happens to you, just calmly re-display the main toolbar, and open the left, Navigators area. Hide the bottom bar, and you’ll be back to a normal “project window.”

        Execution Controls
        To match the iTunes-like single-window interface, the Xcode 3 Build and Run/Stop buttons have been replaced in Xcode 4 with simple Run and Stop buttons in the main toolbar:

        The default shortcuts for Building (Cmd-B), Running (Cmd-R), and Cleaning (Shift-Cmd-K) remain the same under Xcode 4—the menu commands are found under the Product menu.

        In the middle of the toolbar is a status area, again much like iTunes, to indicate what’s going on. If a Build fails with errors or generates warnings, these are indicated in this area.

        Notice also that if errors or warnings are generated, these are displayed in the Issue Navigator pane on the left, which will appear automatically if issues are found. This Issue Navigator (Cmd-4) replaces the separate Build Results window under Xcode 3. As before, errors and warnings are displayed as overlays on top of the relevant code:

        And, as mentioned earlier, when you want to get back to the list of files in the project you’ll need to switch to the Project Navigator pane (Cmd-1).

        Editors
        Xcode 4 has a variety of editor “modes,” including an Assistant editor. Any time you open a file when using the Assistant, Xcode 4 will also display what it thinks is the most closely-related file (such as the class interface header file for a class implementation).

        Switch to the Assistant by using the Editor segmented control in the main toolbar, or choose View > Editor > Assistant (Opt-Cmd-Return):

        Health Warning: Use of Xcode 4 may cause extreme desire for a larger monitor/display

        If you prefer viewing just one file at a time, you can use the Related Files popup menu to jump between counterparts, and even superclasses, protocol definitions, etc:

        Note that the default shortcut to display the counterpart file (i.e., jump from an implementation file to an interface file), has changed from Opt-Cmd-UpArrow to Ctrl-Cmd-UpArrow. Take a look at the list of Jump commands in the Navigate menu for a full list of helpful shortcuts.

        The third editor, the Version editor, is used for projects under a source code Version Control System, e.g. Git or Subversion. Versioning isn’t something covered in the book, but it’s a great addition to Xcode for when you start using a system like Git.

        Integrated Interface Builder
        Interface Builder used to be a separate application, which would communicate behind the scenes with the Xcode 3 environment to make sure relevant code changes were represented in the interface. There were a few gotchas with this, including the need to save .xib or .nib files in Interface Builder before Building and Running in Xcode.

        Under Xcode 4, the entire interface-editing environment has been integrated into the Xcode application itself.

        When you click a .xib file, it will open in the editor:

        The left hand side of this editor pane contains the icons representing the objects within the .xib file. If you click the window icon, the window will appear in the pane:

        The blue box surrounding the window in the graph paper area includes a Close button to hide the window from the editor; if you need to show lots of objects in the editor pane, you can drag the blue box containers to rearrange items.

        Inspectors
        The object inspectors are no longer found under separate panels in Xcode 4; instead, you’ll need to use the main toolbar View segmented control to display the “right bar,” or Utilities area:

        The top half of this Utilities area contains Inspector panels. Just like Navigators on the left of the window, you use the little icon buttons to swap between the different inspectors, which also have corresponding menu items and keyboard shortcuts:

        Libraries
        The lower half of the Utilities area is used for Libraries. Again, use the little icon buttons to switch between them (or use the menu options shown above). For interface editing, you’ll need the Object Library (Ctrl-Opt-Cmd-3):

        Making Connections
        IBOutlet and IBAction connections are made in the same way as they were in the standalone Interface Builder.

        If you’re making a connection from one of several objects in the left-hand column of the Interface Editing panel, hover over any icon to show its class name:

        Right-click (or Ctrl-click) to show the available connections, and click-drag out from the circle to make the connection:

        Under Xcode 4, there’s also another connection option available if you use the Assistant Editor.

        The Assistant Editor will display the class interface that it thinks is most closely related to the objects in a .xib file; for the TextApp application, this will likely be the TextAppAppDelegate.h file. Given that the connections you’ll need to make in the book are initially for the NotifyingClass object, you’ll need to use the Assistant’s file dropdown to choose one of the other related files, NotifyingClass.h:

        Once you’ve done this, Xcode 4 allows you to make connections directly to the IBAction and IBOutlet entries in the code file:

        You’ll need to hover over the code until the words “Connect Action” or “Connect Outlet” appear; if you hover in an empty area, or between lines, Xcode 4 will insert an action or outlet automatically at the code location where you release the mouse button.

        If you hover in one place for two long, Xcode 4 may “drill down” into the code, and show you superclass interfaces, etc. If this happens, either use the file dropdown mentioned above, or the back/forward buttons at the top left of the assistant’s code file panel:

        Project Template Changes
        The templates seem to change with every minor revision of Xcode. For Xcode 4 onwards, you’ll find the organization of the project is slightly different from that shown in the book for Xcode 3. You should find that the files still have the same names, but the Classes group now has the name of your application, and the various resources and other sources are now found either inside this group or inside its Supporting Files group.

        The code that’s included in the project templates has also changed a little. You’ll find that any provided init method, which used to look like this:

        – (id)init
        {
            if (self = [super init]) {
                // Initialization code here.
            }
           
            return self;
        }

        now looks like this:

        – (id)init
        {
            self = [super init];
           
            if (self) {
                // Initialization code here.
            }
           
            return self;
        }

        One change in Xcode 4 that may cause confusion is that you’ll now get a warning if you use the first style—you’ll now get a warning any time you use an assignment inside a conditional if() statement. If you are particularly attached to using this style, you’ll need to add an additional set of parentheses to silence the warning:

        – (id)init
        {
            if ((self = [super init])) {
                // Initialization code here.
            }
           
            return self;
        }

        Mac Tips and Tricks

        0
        0

        Get all Mac OS X Tips, Tricks, Tutorials, Hacks, Support, Downloads, Updates…right in to your Mac OS X Mountain Lion, Lion, Snow Leopard, Leopard or Tiger Dashboard !
        Learn How To using Finder, Preview, iChat, iCal, Mail, Safari, Address Book, Expose, Dock, Dashboard, Spotlight, Keyboard Shortcuts…or Customizing Your Mac !
        ↓ Download

        LionTips

        0
        0

        Get Mac OS X 10.8 and 10.7 Tips, Tricks, Tutorials, Guides & How To’s right in to your Mac OS X Dashboard.
        ↓ Download


        Mac Tips and Tricks

        0
        0

        Get all Mac OS X Tips, Tricks, Tutorials, Hacks, Support, Downloads, Updates…right in to your Mac OS X Mountain Lion, Lion, Snow Leopard, Leopard or Tiger Dashboard !
        Learn How To using Finder, Preview, iChat, iCal, Mail, Safari, Address Book, Expose, Dock, Dashboard, Spotlight, Keyboard Shortcuts…or Customizing Your Mac !
        ↓ Download

        MacSupport – Tips

        0
        0

        Get Mac OS X Support, Tips, Tricks, Tutorials, Guides & How To’s right in to your Mac OS X Dashboard.
        ↓ Download

        MacSupport – Software

        0
        0

        Get Mac OS X Support of all Apple Software products right in to your Mac OS X Dashboard.
        ↓ Download

        FreeDownloads

        0
        0

        Get Free OS X Apps, iOS Apps, Music, Books, Help, Support, Updates and what ever you need to optimize your Mac, iPhone, iPad or iPod Touch right from your Mac OS X Dashboard.
        ↓ Download

        iWork Tutorials

        0
        0

        Watch iWork video tutorials that show you how to create and enhance your documents in Pages, spreadsheets in Numbers, and presentations in Keynote right from your Mac OS X Dashboard.
        ↓ Download

         

        MacTips

        0
        0

        Get all Mac OS X Tips, Tricks, Tutorials, Hacks, Support, Downloads, Updates…right in to your Mac OS X Dashboard.
        ↓ Download





        Latest Images