Archive for 'Programming'

Library: geo-location-javascript

Here’s a library of interest to our web-developing friends; geo-location-javascript, which wraps a number of different device’s GPS capabilities into a JavaScript API that is “aligned” to the W3 Geolocation API specification:

Usage Scenario

The framework provides two key methods, it determines if the handset has client side geo location capabilities and one method to retrieve the location (of course only after a request for permission). So a mobile web site that provides location based services can first determine if the client has client side geo capabilites and ask him to assist him in finding his location. If no geo capabilities are given or they are disabled the site can fallback on a manual location input method and use a geodata database/service to map the input to a pair of latitude/longitude coordinates.

Supported platforms

  • iPhone OS 3.x
  • Browsers with Google Gears support (Android, Windows Mobile)
  • Blackberry Devices (8820, 9000,…)
  • Nokia Web Run-Time (Nokia N97,…)
  • webOS Application Platform (Palm Pre)
  • Torch Mobile Iris Browse
  • Mozilla Geode

A comprehensive — nay, well-nigh exhaustive — list of platforms indeed!

As a side note, if you’re unfortunate enough to be stuck on a Windows platform and would like to have an iPhone (and Pre, and …) emulator to test out your webpages, there’s this MobiOne thing which looks like it could be useful for you, check it out.

h/t: iPhoneWebDev!

Continue Reading →

Source: XPilot

Here’s another GPL’d game ported to the iPhone, like World Challenge that we mentioned earlierXPilot, an old school multiplayer game that now has a new lease on life. But, as we pontificated in the World Challenge notes, there are those who have issues with this kind of resurrection; and in this case, it includes one of the original developers. From the Slashdot article “The Ethics of Selling GPLed Software For the iPhone”:

…We priced it at $2.99 on the App store (we don’t expect it to become the Next Big Thing, but hoped to recoup our costs — such as server charges and Apple’s annual $99 developer fee), released the source on our web page, then enthusiastically tracked down every member of the original community we could find to let them know of the hoped-for renaissance. Which is where things got muddy. After it hit the App store, one of the original developers of XPilot told us he feels adamantly that we’re betraying the spirit of the GPL by charging for it.

This would be the kind of person that Fake Steve Jobs coined the term ‘freetard’ for. The GPL not only doesn’t mandate a price of nothing, it explicitly allows the charging of whatever fee you see fit for distribution, so long as all source is made available. So nobody serious believes that said original developer has any point. But it does bring up where the real debatable point is, since you can’t recompile on your own phone or redistribute through the App Store without the $99/yr licensing fee by Apple, does that constitute a violation? If you read through the 581 and counting comments, you’ll see every shade of opinion … including a link to the one that we can take as authoritative, I have no doubt: Brett Smith. And who is Brett Smith, you ask? Why, he’s the “Licensing Compliance Officer” for the FSF. Seems that this subject was brough up last year with him over at, and here’s the scoop: There is no barrier the FSF sees to GPLv2 compliance. However, GPLv3 is off the table:

…The iPhone Developer Program establishes Apple as the sole provider of iPhone applications. You can choose not to charge for an app you author, but the iTunes Store is the only channel through which it can be delivered to end users and installed. Apple signs the apps it approves with a cryptographic key. Unsigned apps won’t run on the iPhone.

This condition conflicts with section 6 of the GPLv3, the so-called “anti-TiVoization” provision. In particular, it prohibits Apple from distributing a GPLv3-licensed iPhone application without supplying the signing keys necessary to make modified versions of the application run, too.

Thus, you as the developer could attempt to place your code under the GPLv3, but Apple could not distribute it — and since only Apple-signed programs will run, no one else could distribute it either.

The FSF’s Smith says the fact that the author of the program (i.e., you) and the distributor of the binary (i.e., Apple) are unrelated entities makes no difference. “If a program is meant to be installed on a particular User Product, GPLv3 imposes the same requirements about providing Installation Information whether the software is directly installed on the device or conveyed separately.”

Because of the GPL’s viral nature, any app that is derived from other GPLv3 code must be licensed in a way that preserves GPLv3’s code signing requirement. But there are still projects that have chosen to retain earlier licenses, such as GPLv2, and prior versions of the GPL did not include the code signing requirement. Thus you could in theory place your work under GPLv2, as long as it was either entirely original or derived only from code licensed under GPLv2 and earlier…

So there you go, we’ve got that question officially settled then; any program licensed under GPLv2 is cool with the FSF for the App Store, long as you make the source available. Excellent. Soon as we find some free time under the couch or something we will definitely look at picking a project like these to port to the iPhone for the benefit of those who enjoy rooting through code written by their potential contract trolls.

In the meantime, support these fellows’ trailblazing efforts, pick up what all the fuss is about for a mere $1.99!


Continue Reading →

UI Design Patterns

If you’ve got anything to do with designing iPhone interfaces — on paper or not — do not miss this post over at the new to us but worthwhile looking Flyosity blog about the advantages and disadvantages of different types of conventional iPhone application view organization

These three main interaction concepts correspond to three different types of View Controllers: Navigation Controllers, Tab Bar Controllers, Modal View Controllers and Table View Controllers respectfully. These are the building blocks for crafting iPhone applications.

and designing custom interfaces as well, with several paradigms of each type. Nothing overly surprising, but a nicely crafted overview, and the custom examples chosen are particularly interesting.

h/t: Daring Fireball!

Continue Reading →

iPhone Stencil Kit

Now here’s something that we bet you didn’t see coming as an aid to your iPhone UI design: a stainless steel stencil. Yes, the kind that works with paper.


Personally, we figure Interface Builder live design is the way to go when trying out interface ideas … but hey, there is a body of opinion out there that believes in paper prototyping, and if you’re one of them, this is for you, indeed. Besides, it just looks cool, doesn’t it now?

h/t: LinkedIn!

Continue Reading →

GUI Elements with Keynote

Now here’s a clever-sounding workflow for whipping together some reasonably attractive non-standard GUI elements for your iPhone project in short order; particularly useful for trolls, who as artists are really good programmers, if you get our drift.

Turns out that Keynote, which chances are fairly good you probably have on your machine even if you didn’t realize it as part of iWork, is very good at creating custom buttons and the like.

Then he recommends you just shimmy the shapes Keynote produces through the Acorn image editor, which apparently handles them quite gracefully — we wouldn’t know, so far we’ve found GraphicConverter the heartwarmingly geekiest of bitmap editors for us, but when we give this plan a whirl next time we want a funky button we’ll try out Acorn if GraphicConverter happens to not handle Keynote creations gracefully — et voilà, you have Xcode/IB-ready graphic files!

Easier to watch than describe, check out the video to see a demonstration.

We also note from the comments that OmniGraffle is suggested for this kind of designer-challenged design as well, so there’s another option.

h/t: iPhoneFlow!

Continue Reading →

Snippet: NaturalDates

Snippet time again: here’s an NSDate category for you to easily provide “Today”, “Yesterday” etc. in style, which is a friendly kind of thing to do when you have a date denoted kind of list:

@implementation NSDate (NaturalDates) 

- (BOOL)isSameDay:(NSDate*)anotherDate 
   NSCalendar* calendar = [NSCalendar currentCalendar]; 
   NSDateComponents* components1 = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:self]; 
   NSDateComponents* components2 = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:anotherDate]; 
   return ([components1 year] == [components2 year] && [components1 month] == [components2 month] && [components1 day] == [components2 day]); 

- (BOOL)isToday 
   return [self isSameDay:[NSDate date]]; 

- (BOOL)isYesterday 
   NSCalendar* calendar = [NSCalendar currentCalendar]; 
   NSDateComponents *comps = [[NSDateComponents alloc] init]; 
   [comps setDay:-1]; 
   NSDate *yesterday = [calendar dateByAddingComponents:comps toDate:[NSDate date]  options:0]; 
   [comps release]; 
   return [self isSameDay:yesterday]; 

- (BOOL)isLastWeek 
   NSCalendar* calendar = [NSCalendar currentCalendar]; 
   NSDateComponents *comps = [calendar components:NSWeekCalendarUnit|NSDayCalendarUnit fromDate:[NSDate date] toDate:self options:0]; 
   NSInteger week = [comps week]; 
   NSInteger days = [comps day]; 
   return (0==week && days<=0); 

- (NSString *)stringFromDateCapitalized:(BOOL)capitalize; 
   NSString *label = nil; 
   NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
   NSString *dateFormatPrefix = nil; 
   [dateFormatter setDateStyle:NSDateFormatterNoStyle]; // Will display hour only, we are building the day ourselves 
   [dateFormatter setTimeStyle:NSDateFormatterShortStyle]; 
   if([self isToday])
      if(capitalize) dateFormatPrefix = NSLocalizedString(@"Today at", @""); 
      else dateFormatPrefix = NSLocalizedString(@"today at", @""); 
   else if([self isYesterday])
      if(capitalize) dateFormatPrefix = NSLocalizedString(@"Yesterday at", @""); 
      else dateFormatPrefix = NSLocalizedString(@"yesterday at", @""); 
   else if([self isLastWeek])
      NSDateFormatter *weekDayFormatter = [[NSDateFormatter alloc] init]; 
      // We will set the locale to US to have the weekday in english. 
      // The NSLocalizedString(weekDayString, @"") below will make it 
      NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; 
      [weekDayFormatter setLocale:locale]; 
      [locale release]; 
      [weekDayFormatter setDateFormat:@"EEEE"]; 
      NSString *weekDayString = [NSString stringWithFormat:@"%@ at", [weekDayFormatter stringFromDate:self]]; 
      dateFormatPrefix = NSLocalizedString(weekDayString, @""); 
      [weekDayFormatter release]; 
      [dateFormatter setDateStyle:NSDateFormatterShortStyle]; // Display the date as well 
   if(dateFormatPrefix != nil)
   { // We have a day string, add hour only 
      label = [NSString stringWithFormat:@"%@ %@", dateFormatPrefix, [dateFormatter stringFromDate:self]]; 
   { // Use the full date 
      label = [dateFormatter stringFromDate:self]; 
   [dateFormatter release]; 
   return label; 


… yes, we know, it’s just about impossible to actually read the code, we really must get around to finding the time to sort out a theme with a light background and none of this dumb wrapping. One of these days…

h/t: iPhoneSDK!

Continue Reading →

iPhone Recipes submissions

Got any iPhone code snippets that demonstrate your cleverness? Well, here’s an opportunity to show them off:

We’re looking for bite sized recipes for our “iPhone Recipes” book to be published by the Pragmatic Bookshelf. This is your opportunity to show your chops to the community as a whole. In particular, we’re looking for easily understandable, general purpose recipes that aren’t already well documented. We’re not asking you to share your application’s secret sauce, just a few of the toppings.

To propose a recipe idea, here’s what we need from you:

A paragraph or two describing the problem that the recipe solves.
A sentence or two indicating what the solution will be.
The OS version(s) to which the recipe applies.

Email your idea to us at by August 1st (or sooner!)

If your recipe is selected, your name, bio, and a link to your site/blog will appear in the book. You’ll also receive a complimentary copy of the book, of course.

Well, that’s a nice try at getting people to write you a book for free, appeal to their vanity, isn’t it now? Be interesting to see how this works out for them! If we can find some spare time before August 1st it’ll probably work on us, after all…

Continue Reading →

Snippet: Texture Sizes

Here’s a cute little snippet for automatically transmogrifying your OpenGL textures into iPhone-acceptable dimensions at runtime if you don’t want to go to the trouble of sorting out the source assets, because maybe you’re porting existing assets from another platform, or your artists can’t follow directions, or whatever:

First off, figure out power-of-two dimensions:

  1. //     Adjust the width and height to be a power of two
  2. if( (_width != 1) && (_width & (_width – 1)) )
  3. {
  4. i = 1;
  5. while((sizeToFit ? 2 * i : i) < _width)
  6. i *= 2;
  7. _width = i;
  8. }
  9. if( (_height != 1) && (_height & (_height – 1)) )
  10. {
  11. i = 1;
  12. while((sizeToFit ? 2 * i : i) < _height)
  13. i *= 2;
  14. _height = i;
  15. }

You could figure that out on your own no doubt, but you might miss this; if it turns out that the image is too big, your friend CGAffineTransform can sort that out for you!

  1. //      scale down an image greater than the max texture size
  2. while((_width > kMaxTextureSize) || (_height > kMaxTextureSize))
  3. {
  4. _width /= 2;
  5. _height /= 2;
  6. transform = CGAffineTransformScale(transform, 0.5, 0.5);
  7. imageSize.x *= 0.5;
  8. imageSize.y *= 0.5;
  9. }

That’s quicker than going through and canonizing a large asset base yourself, indeed. Read the rest of the article for further explanation; and this is part of the D’Jinn Engine for the iPhone which can be found on Google Code. Enjoy!

h/t: iPhoneDevelopmentBits!

Continue Reading →

Tutorial: Proximity Monitoring

More of a snippet this time than a tutorial really, over in the MobileOrchard iPhone 3.0 series; how you can now be as cool as Google.

When Google released their iPhone app last year it was accompanied with a bit of controversy:

Their app used an undocumented API to detect when the phone had been placed next to the speaker’s ear.

In iPhone 3.0 SDK this API is usable by any app. This short article demonstrates how to use it:

Actually, it hardly needs a demonstration — all that there is to do to get your monitoring going is set [UIDevice currentDevice].proximityMonitoringEnabled = YES; and listen for the notification.

But hey, if you still had the impression from the brouhaha over Google getting to be special that normal developers weren’t allowed to do the same thing — now you know how you can too!

Continue Reading →

No doubt you’re already aware that many developers are upset about the apparent, ah, capriciousness of the App Store approval process. Whilst we’re certainly no strangers to that feeling ourselves — at the moment we have one set of apps on the store with a known crash on 3.0 that Apple won’t approve a fix for, and another app that’s been ‘In Review’ seventy-three days and counting — we haven’t gone out of our way to whine about it because really, what would that accomplish? But here is a truly splendid rant on the subject which talks about the problems with getting apps approved that are written with the PhoneGap project for building native, well native-ish, apps with JavaScript. Short version: Don’t try it.

But aside from the amusement factor, this led us to a site that did look like a good idea;, which is a compendium of rejection reasons that developers have provided. That would be useful information to keep track of, indeed! However, it seems to have only been active for a few days back in May, so apparently whoever put it up had second thoughts. Or maybe just nobody’s submitting anything. So if you do have an interesting rejection letter, we encourage you to send it to AppRejected and share with us all!

[EDIT: Here’s another blog dedicated to amassing rejection reasons. Support them all!]

h/t: Slashdot!

Continue Reading →
Page 78 of 99 «...5060707677787980...»