Archive for 'Programming'

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 →
0

Snippet: NaturalDates

Snippet time again: here’s an NSDate category for you to easily provide “Today”, “Yesterday” etc. in Mail.app 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 
      localized. 
      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]; 
   } 
   else 
   { 
      [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]]; 
   } 
   else
   { // Use the full date 
      label = [dateFormatter stringFromDate:self]; 
   } 
   [dateFormatter release]; 
   return label; 
} 

@end 

… 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 →
5

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 submissions@iphonerecipesbook.com 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 →
0

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 →
0

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 →
1

AppRejected.com

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; AppRejected.com, 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 →
1

iPhoneSimulatorExchange

Here’s a handy little tool to add to your bag of iPhone programming tricks: iPhoneSimulatorExchange! What it’s for is to — wait for it — exchange iPhone Simulator binaries, eponymously enough:

Create 1-click installers of your iPhone Simulator apps to share with other developers for testing. Or to send it to someone to create Screencasts for reviews.

There’s actually been a good number of times when we just wanted a client’s feedback on a proposed workflow or the like and we’d wished that there was a way to get something quickly without the whole send me your device ID let me issue a new provisioning certificate now try and get iTunes to recognize it yadayadayada. And especially when we needed something signed off on by someone who doesn’t actually have an iPhone at all. Yes, that happens. But finding any old Mac to install the SDK on, now that’s a great deal less of a burden! So we’re quite looking forward to using this. It seems brain dead simple, start it up and it shows the apps installed in your simulator,

simulatorexchange.png

then just click the ‘Build Installer’ button and it creates a one-click installer with your splash screen, like

exchanger.png

Double-click that, and it proceeds to install itself. Could it get any simpler? We think not. Yes, we can see this making working with clients a good deal less hassle, indeed. Much thanks to these GrandTotal fellows for this!

Continue Reading →
7

Outsourcing testing

Here’s a service to be aware of if you’re doing some desktop Mac development and need a beta tester pool, or if you’re the kind of user that glees in poking around in buggy prerelease software: MacDeveloper.net, from the same people who run the most excellent prMac press release service for your Mac and iPhone press release needs. And what is MacDeveloper.net exactly, you ask?

MacDeveloper is an opt-in service for testers who love what the Mac community offers and genuinely want to test. We feel the platform is an excellent alternative to Bundled software avenues. At the same time a developer’s software is being tested, they’re also giving back to the community who supports them.

MacDeveloper makes it fun for Beta Testers. Register to test your favorite software and receive coupons for FREE software, or purchase software at huge discounts.

MacDeveloper for Testers

   * Register and Test software absolutely free

   * Choose only the Software Categories that interest you

   * Earn Points for Testing your favorite Software

   * Use points to purchase software for FREE

   * Use points to purchase software for huge discounts

   * Earn valuable Star Ratings for being a Quality Tester

MacDeveloper for Developers

   * Create Project Channels for only $18.75

   * Upload as many binaries to Project Channels as you wish

   * Search the Beta Pool for Quality Testers

   * Find Beta Testers who genuinely have a desire to test

   * Use Coupons for Testers to purchase your Applications for free or at a discount

   * Excellent method for customer building

We haven’t happened to use it ourselves yet, but if one was to be looking for something a bit more structured than a public beta but didn’t have an inhouse QA staff or the budget for hiring out, this certainly does look like something worth giving a shot; there seems to be a pretty good selection of happy users, anyways, so apparently it works out pretty good for at least some people.

Of course, if even this much effort in beta testing strikes you as too much, there’s always the ‘call the first build that doesn’t burst into flames at launch the “Preview Edition” and start charging for it’ strategy…

Continue Reading →
2

Library: boost for iPhone

Here’s a handy link if you have any boost-using code you need to port over to the iPhone … well, if you want to use anywhere, actually; coding maven Jeff Koftinoff has released a streamlined version called jdksboost:

This version only changes minimal source code from the boost trunk. The objective of the changes to boost is purely to re-arrange the source files so that a simpler build system can be used…

The current standard for building the library files for boost involves a build tool called bjam which is powerful but not easily integrated into the other build environments that I needed.

I decided that for some tools, like Microsoft Visual Studio and iphone and Mac OS X leopard, I really needed all of boost to be compiled by the same IDE project management tool so that I could make sure that all the various compile and linker options were applied correctly between the libraries and my main project…

Useful by itself no matter where you’re using this; and for iPhone developers in particular,

  • Apple iPhone targets are supported with an XCode 3.1.3 static library target.
  • Endian and long double changes to boost to allow compilation for iPhone hardware as well as the iPhone simulator target.

So there you go, grab the source and enjoy!

Continue Reading →
0

Source: World Challenge

Now here’s something we’d sorta been pondering ourselves might be worth doing; this fellow’s taken the GPL’d crossplatform game Tux Racer and ported it to the iPhone

tuxrider

… for $3.99. Whilst providing a desktop build for free, and source downloads at the bottom of the product page which apparently this fellow feels meet the terms of the GPLv2 sufficiently.

We say “apparently”, because there is a body of opinion out there that since the casual consumer cannot edit the source code to an App Store-bought application and run the edited program directly on their phone, it is impossible to comply with the terms of the GPL with an application distributed through the App Store. We don’t subscribe to that personally, mind you; first off, nowhere in GPLv2 does it explicitly state that you must be able to run it on the distributed device — so being able to run your modified code in the simulator, which requires nothing but the freely downloadable Xcode toolchain, arguably satisfies the license adequately. And even if you do insist that the terms implicitly require that you run the modified version on the distributed device, then we don’t think that the $99/year developer program fee to Apple to be able to run whatever source you like on your phone is a condition that amounts to a GPL violation, any more than needing to buy a commercial compiler to do something useful with any desktop GPL’d source would violate it. But as the Free Software community is disproportionately populated with Apple-haters, mere logic is not always sufficient to appease them; and as this (to our knowledge) is the first GPL-licensed iPhone program that anyone has attempted to charge money for, if there is anyone out there willing to test their anti-iPhone interpretation of the GPL in court, well, this is whom they’d probably pick for a test case.

So we’ll be watching to see if any of the huffers and puffers get all indignant about this fellow’s entrepreneurial bent; and if not, we’ll probably look for some GPL’d game to port ourselves, as we would rather like to have an open source iPhone project to direct those who would like to see some demonstration of our coding practices to, and hey if it might make a buck or two that’s always great as well! In the meantime, if you’re a desktop Tux Racer fan, and not a programmer yourself — buy it to encourage more GPL’d source ports!

World Challenge

Colophon:Well, today was to be the final client-provided post of The Great WordPress Client Test, finishing up with über-text-editor

TextMate

TextMate 1.5.8!

but the actual testing ends up a DNF, as we couldn’t be bothered actually getting TextMate to work. See, its blogging extension’s bundle’s idea of configuration is to have you put your blog’s XMLRPC address in a text file. We gave it a couple tries at what we think that address should be for this blog, but it failed to make them work. And we figured we just wouldn’t bother to keep trying, since obviously there wasn’t going to be any useful conveniences here at all, so at best it would make it into the same class as the other non-WYSIWIG tools. So we’ll award it 2/10 to put it at the bottom of our ratings due to its completely beyond the pale requirement of “needing a clue about blog internals” and leave it at that.

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