Archive for June, 2008

Jun 11 2008

iPhone SDK, First Impressions

Published by john under iPhone

I’ve been spending some time with the iPhone SDK to get a perspective on the architecture, tools and overall landscape. In addition, I’ve started to develop a few applications with Xcode (Cocoa/Objective-C) to exercise the tools for building iPhone applications. More on application development next week…

So far, I’m impressed. Here’s how I see things…

The Platform:
The iPhone architecture consists of the Core OS (kernel level resources), Core Services (system services), Media (audio, video and graphics) and Cocoa Touch (classes for managing graphics and event-driven applications).

From my perspective, there are two key areas that are exposed. First, the system services in Core OS, accessible through a C library (LibSystem) where one can work with wrappers for low-level features such as threading, networking, file system, Bonjour, among others.

Second, and even more compelling from a user interaction perspective, is the Media layer. Quartz is a 2-D drawing engine. Through the C-based API one can work with vector graphics, lines and shapes, etc. Core Animation is an Objective-C API providing animation and is also part-and-parcel to providing dynamic feedback from the UI. Many of the standard animations that make the iPhone so compelling (screens sliding, flipping over, etc) are included in View classes in the UIKit. OpenGL ES is a mobile version of the OpenGL standard and is the engine behind 3-D graphics. When high-frame rates are in order (think games), OpenGL is the answer.

From what I can tell, the iPhone SDK looks quite comprehensive, providing access across all areas of the device.

Distribution:
One of the challenges since day one for mobile developers has been getting their applications in front of potential users. With the iPhone, applications will be available through Apple’s App Store, which is accessible on the phone as well as through a desktop/laptop system. My understanding is that Apple will offer developers 70% of the revenue. Not unreasonable given Apple will provide the store front and manage all that goes with it.

Overall, an impressive start to what I think could be a significant, and welcome change, to the mobile development landscape.

Technorati Tags:

No responses yet

Jun 10 2008

TextMate: Working with Comments

Published by john under TextMate

In a recent email exchange with Allan Odgaard, creator of TextMate, I asked if he had any suggestions for tips that would make for a good screencast. Allan mentioned that on the TextMate IRC, there are often questions about working with comments. And with that, he shared a list of tips that you’ll find in the video that follows.

There are five tips on working with comments, including toggling comments on/off, commenting a subset of a line, inserting comment blocks and a short section on how to insert todo lists inside a comment block.

Summary of tips:

  • Apple-/ Togggle comment
  • Alt-Apple-/ Comment a block and comment subset of a line
  • “head” tab-key Insert comment header at top of file
  • Control-Shift-B Insert comment banner (top of declaration, function, etc)
  • “todo” tab-key Insert todo block

Note: In order for these features to work, you will need to make sure the Source and TODO bundles are enabled within TextMate (see the video for more information).



The music in the video is J.J. Cale and the song: Call Me the Breeze.
Click to hear a longer clip of J.J. Cale:

Technorati Tags: ,

4 responses so far

Jun 09 2008

Sponsor: Give Good Food to Your Mac

Published by john under Sponsors

I’d like to introduce (and thank) another sponsor of Mac Developer Tips: Give Good Food to your Mac is a two week promotion, coinciding with the kickoff of the World Wide Mac Developer Conference, that is offering an intriguing assortment of tools and utilities for developers. From database tools such as DBVisualizer to REALBasic cross-platform IDE to SourceGaurdian PHP encoder, there is assortment of interesting software.

To see what Give Good Food to Your Mac has to offer, click on the banner ad to the right or one of the links in this post (no, I am not paid on a per-click basis :) and spend a few minutes to check out some of the tools and utilities. There are discounts from 20 to 50% while the kitchen is open between the 9th and the 23rd of June 2008.

Here’s a quote from the creators of the promotion that sheds a little light into the name and intention:

No junk food, just healthy, tasty and innovative products. And because we are speaking ‘haute cuisine’ everybody gets to create their own combination of titles matching their own and unique taste.

No responses yet

Jun 06 2008

At Least They Are Consistent…

Published by john under Humor

I’ve been searching for an “ergonomic” keyboard recently and figured I owed it to myself to give one of the Microsoft split keyboards a go.

The keyboard is fine, if not unusual. I find myself spending a fair amount of time looking at the keys as I type since my index fingers have typically done this goofy crossing-over each other reaching for keys that should of been handled by another finger (alas, the split keyboard idea). If nothing else, my typing is much slower and more methodical. The jury is still out on whether this is the best solution of me to ease some of the stress of typing…

What I find rathering amusing is that MS pops up the following warning during the install process:

If you’ve spent any amount of time working on an MS platform, or even if not and you’ve read about the frustrations, you’ll understand the irony behind this dialog and why as a Mac user, it’s amusing.

For what it’s worth, I’ve decided to make Friday’s posts things that are not as much tips as something more on the humorous side. If you have ideas and suggestions, drop me a note.

Technorati Tags:

2 responses so far

Jun 03 2008

Using a String as a File in Ruby

Published by john under Ruby

The ability to treat a string as a file can often be quite handy. Generally this most useful when classes/methods expect a file object as an input type. With Ruby, you can use the StringIO library to use a string when a file is expected, thus allowing operations such as read, write, rewind, etc.

In the lines below, the code after the #=> shows the results when executing the script. Follow the code to see several examples of a string using operations that are typically reserved for files.

require 'stringio'
str = StringIO.new %{This is a test of a string as a file. \r\n
                     And this could be another line in the file}

# Get a line
str.gets # => "This is a test of a string as a file. \r\n"

# Get the next 18 charaters
str.read(18) # => " And this could be"

# Seek to new position and read 7 more characters
str.pos = 59  # => 59
str.read(7) # => "another"

# Rewind the file and overwrite some of the existing text
str.rewind
str.write("Here's how to use")

# Rewind again and output the new contents
str.rewind
str.read # => "Here's how to use a string as a file.
     \r\n And this could be another line in the file"
str.eof? # => true

Any easy way to work with a string in a method that is expecting a file is to create a new StringIO object and pass the result to the method requiring a file type. For example:

  some_method(StringIO.new("Your string here"))

Technorati Tags: , ,

3 responses so far

Jun 02 2008

Using a Stack with Ruby

Published by john under Ruby

Although an array within Ruby supports all the operations you need for working with a stack (push, pop, etc), the problem is, Ruby does not offer a “formal” stack object and therefore the flexibility of the Ruby array can present problems. For instance, even if you intend to treat an array as a stack, nothing will stop you (or another developer using your code) from inserting or deleting anywhere within the stack.

We can work around this by creating a simple Stack class as follows:

class Stack

  def initialize
   @the_stack = []
  end

  def push(item)
    @the_stack.push item
  end

  def pop
    @the_stack.pop
  end

  def count
    @the_stack.length
  end
end

Here is how you might use the stack:

  stack = Stack.new
  stack.push('abc')
  stack.push(100)
  stack.count
  stack.pop()

If need be, you could also add a few convenience methods such as clearing the stack or looking at the last element (without popping it off the stack):

  def clear
    @the_stack.clear
  end

  def look
    @the_stack.last
  end

Give this a try if you need to work with an array as a stack and want to play within the rules of how a stack is implemented as a traditional data structure.

Technorati Tags: ,

2 responses so far

« Prev