An enhancement for UIAlertView

February 19th, 2010 by Jeff

I like objective-c protocols, and I am a fan of the interface oriented designs that it allows for. But, sometimes the indirection of using a selector with a defined signature just works better, and the problem is that UIAlertView does not take a selector. Instead, UIAlertView defines a protocol, UIAlertViewDelegate, that the alert’s delegate adopts to receive notification of the user intent. To be fair, UIAlertView communicates a bit more information back to it’s delegate than the target of an NSAlert, and the UIAlertViewDelegate protocol does a fine job achieving that goal. 99% of the time, however, I want to show an alert and have it call my named selector when it is done. To that end, I finally busted out the admittedly tiny class that does the job.

Now in my client code I show an alert like this:


    RSAlert* alert = [[RSAlert alloc] initWithTitle: @"Title" 
                                            message: @"Message!" 
                                             target: self 
                                           selector: @selector(dismissedAlert:buttonIndex:)
                                  cancelButtonTitle: @"OK" 
                                  otherButtonTitles: nil];

and handle the result with a selector, similar to NSAlert:


- (void) dismissedAlert: (RSAlert*) alert buttonIndex: (NSInteger) buttonIndex
{
    NSLog(@"dismissedStartupAlert with buttonIndex: %d", buttonIndex);
    
    [alert autorelease];
}

I realize this is an infinitesimally small annoyance, but sometimes it’s the little things that keep us happy.

RSAlert.h


#import 

@interface RSAlert : NSObject 
{
    UIAlertView*    alertView_;
    id              target_;
    SEL             selector_;
}

- (id)initWithTitle: (NSString*) title 
            message: (NSString*) message 
             target: (id) target 
           selector: (SEL) selector
  cancelButtonTitle: (NSString*) cancelButtonTitle 
  otherButtonTitles: (NSString*) otherButtonTitles, ...;

- (void) show;

@end

RSAlert.m


#import "RSAlert.h"

@implementation RSAlert

- (id)initWithTitle: (NSString*) title 
            message: (NSString*) message 
             target: (id) target 
           selector: (SEL) selector
  cancelButtonTitle: (NSString*) cancelButtonTitle 
  otherButtonTitles: (NSString*) otherButtonTitles, ...;
{
    self = [super init];
    
    if ( self )
    {
        target_     = [target retain];
        selector_   = selector;
        alertView_  = [[UIAlertView alloc] initWithTitle: title
                                                 message: message
                                                delegate: self
                                       cancelButtonTitle: cancelButtonTitle
                                       otherButtonTitles: nil];
    
        if ( otherButtonTitles )
        {
            va_list argList;
            id anArg;
            
            [alertView_ addButtonWithTitle: otherButtonTitles];
            
            va_start(argList, otherButtonTitles);
            
            while ( anArg = va_arg(argList, id) )
            {
                [alertView_ addButtonWithTitle: anArg];
            }
            
            va_end(argList);
        }
    }
    
    return self;
}

- (void) dealloc
{
    [target_ release];
    [alertView_ release];
    [super dealloc];
}

- (void) show
{
    [alertView_ show];
}

- (void)       alertView: (UIAlertView*) alertView 
    clickedButtonAtIndex: (NSInteger) buttonIndex
{
    // Do nothing
}

- (void) alertViewCancel: (UIAlertView*) alertView
{   
    [target_ performSelector: selector_ 
                  withObject: self 
                  withObject: (id) 0];
}

- (void) willPresentAlertView: (UIAlertView*) alertView
{
    // Do nothing
}

- (void)didPresentAlertView: (UIAlertView*) alertView
{
    // Do nothing
}

- (void)             alertView: (UIAlertView*) alertView 
    willDismissWithButtonIndex: (NSInteger) buttonIndex
{
    // Do nothing
}

- (void)            alertView: (UIAlertView*) alertView 
    didDismissWithButtonIndex: (NSInteger) buttonIndex
{
    [target_ performSelector: selector_ 
                  withObject: self 
                  withObject: (id) buttonIndex];
}

@end

Leave A Comment »

RogueSheep at Macworld 2010

February 9th, 2010 by Chris

Just a reminder that we will be exhibiting Postage and all our iPhone apps at Macworld Expo 2010 in just a few days. If you are planning on attending, be sure to look for us in the Mobile Application Showcase in the expo hall. We’ll be giving out promo codes and some other cool schwag including buttons, and these adorable MOO cards:

Macworld MooCards Blog.png

If you are not yet planning to attend Macworld 2010, there is still time! It looks like some great events are planned this year, including a special iPad event where Macworld editors will have an iPad on hand to show off. There are also a ton of interesting and entertaining speakersthis year including, filmmaker Kevin Smith, the legendary Guy Kawasaki and the cranky, but lovable John Gruber of Daring Fireball.

The Expo takes place from February 11-13 at the Moscone Center in San Francisco. We have a number of free exhibit hall passes to give away. If you are interested, send us an email here : macworld2010@roguesheep.com

Comments Off

Two Apps, one Girl

January 29th, 2010 by Chris

We’ve caught the love bug here at RS HQ and have two great new iPhone applications available in the store this week.

RoseGlobe

RoseGlobe is a romance-themed version of the SnoGlobe application we released last December. RoseGlobe is just beautiful and every bit as mesmerizing to play with as SnoGlobe. Be sure to check out the demo video that Brad created at the product website. It’s almost as pretty as the app itself. I think he is going to create a blog post soon to talk about how he worked the magic to motion capture the iPhone to create the animated phone in the short.

Valentine ~ Postage

We have also created a newly themed edition of Postage for the upcoming holiday next month. Valentine ~ Postage has 14 love inspired postcard designs, one for each day of February leading up to Valentine’s Day. Grab it and send your sweetheart a special little message every day next month. I guarantee it will win you some big relationship points!

Postage ~ Postcards

Finally, we have also updated the premium edition of Postage with several of the new postcard designs form Valentine ~ Postage filling out the love category with ten total designs. Be sure to update if you haven’t done it yet.

Comments Off

iPhone OS 4.0?

January 26th, 2010 by Chris

I know that we are all excited about the mythical Apple tablet materializing tomorrow, but with all the pontification already spread across the far corners of the media, I don’t feel I have much to add to the story. On the other hand, I have been thinking a bit about iPhone OS 4.0. I don’t think we will hear about 4.0 tomorrow if there really is a tablet. It seems like that would just be too much to unload all at once. (I do allow that we might hear about an incremental update such as iPhone OS 3.2 though). Still, we’ll be all out of things to speculate on after tomorrow, so perhaps we can kickstart the next round now?

User Desire

As a user, my hope for iPhone OS 4.0 is a way for third party developers to provide background media playing applications. I understand why Apple wants to be careful with allowing any ol’ process to be granted the ability to run in the background. Sure… power users will be able to manage background processes by hand, no problem. As we have seen on the desktop though, ordinary people just don’t want to be bothered with that level of device tweaking. We have been playing with a few Android devices here at the labs and its clear its pretty easy to start installing apps that quietly add background processes that start to suck down the battery without realizing what you have done.

On the other hand, applications like Pandora on the Android phones are so much better than their iPhone equivalents. Being able to tune in that Pandora radio station and having it play in the background just like the built-in iPod application when you launch another app would change the value of these applications immensely.

My suggestion for how Apple can do this without opening Pandora’s box (zing!) is to create a media service API that allows third party apps to hand media streams off to the iPod player. So the flow would work something like this:

You launch Pandora and use their UI to navigate their music offerings. You tune in the station that suits your current mood and give a bit of a listen. Under the hood Pandora is playing their stream via this new service API that is using the iPod application to serve up the audio. Now, you get the urge to catch-up on your news and launch NetNewsWire for some tasty RSS. When Pandora’s process is terminated the music keeps on playing, because it is the iPod application that is playing the audio. Its all Apple code running in the background, managing how much power is consumed just the way Apple wants, certified to the level of quality Apple is comfortable with, but we get audio from other providers.

There are of course some wrinkles to work out. If I launch the iPod app while a background stream is running, what is ‘Now Playing’? Perhaps the iPod application shows an appropriate image indicating the Pandora app is the current offering and allows you to quickly switch to it. One can even imagine a more sophisticated approach where the Pandora app could provide a plugin bundle that hosts its UI inside the iPod app, though I doubt this is appealing to Apple. There also needs to be some interesting mechanism for the iPod application to ask the originating service for the next or previous media file so that mini-controls that can be used to control the iPod in the background work as expected. Perhaps this is solved through a call-back into a simple code-bundle provided by the third party application? I’ m confident though there is some low impact way to achieve Apple’s goals and still enrich the media-playing experience on the device.

Developer Desire

So that’s my biggest desire as an iPhone user, but what about as an iPhone developer? What I would love to see next is a basic suite of video editing APIs. The problem with the iPhone OS and video right now is that if you want to do anything to process frames of video you need to have your own code to decode the video and re-encode after you have done your processing. This is not exactly trivial code to do well and open source starting points are potentially fraught with licensing and patent peril.

Even if you roll your own codec, perhaps even getting down and dirty with some ARM assembly, you still can’t get access to the built-in hardware assist that allows Apple’s software to capture and encode video at decent performance. The last thing we want to do as an iPhone developer is invest a lot of time in developing a codec for the iPhone and find that the best we can do is H.263 at a miserable frame rate. We also don’t want to force the user to wait around in our application for an encode to finish. Once again we need some way to hand this off and allow the OS to encode in the background for us so our users are not trapped in our application waiting for their edit to finish.

A basic QuickTime derived API that would allow us to take a video file, access individual frames and provide our own sequence of frames to encode into a new movie would be just the ticket. I realize that the advanced encoders typically have licensing requirements and perhaps Apple’s current license for their iPhone software doesn’t allow for this to be opened up. Hopefully it is something that can be addressed in the next version of the OS anyway?

Surely we are in for a interesting ride with the big announcement tomorrow. No doubt the next 6 months will be an interesting one for those of playing with Apple technologies. I suspect WWDC will be chock full of new content this year!

Comments Off

Macworld 2010

January 25th, 2010 by Chris

RogueSheep will be exhibiting at Macworld Expo 2010 this year as part of the Mobile Application Showcase. We will be there showing off Postage and our other iPhone applications, so if you plan on attending Macworld this year be sure and come say hello to us.

If you have never been to Macworld you have been missing out. Its a great time to meet and mingle with Mac and iPhone enthusiasts from around the world. Many of the prominent independent Mac and iPhone developers such as The Omni Group, Rogue Amoeba, FireMint, Riverfold, Marketcircle and Boinx will be presenting their wares there as well. It’s a great way to meet some of the best known names in Mac and iPhone software development.

The expo takes place February 11th-13th in San Francisco’s Moscone Center. We have some passes to give away, so if you are interested in attending drop us a line here : macworld2010@roguesheep.com

Comments Off

Postage and WORD SPIN – 2009 Best App Ever

January 7th, 2010 by Chris

We are honored that both Postage and WORD SPIN have been nominated in the 2009 Best App Ever awards. If you enjoy our apps, please consider heading over to the Best App Ever web site and voting!

Vote for Postage ~ Postcards in Best Visual Design
Vote for WORD SPINĀ® in Best Word Game

Comments Off

iPhone Design Award-Winning Projects

January 6th, 2010 by Chris

Apress has a new book out this month on iPhone application design. The author, Chris Dannen, interviewed a few of us here at RogueSheep. We talked to him about the design and development of Postage which is featured in the book. If you would like a little insight into how we created Postage as well as a look into the development of other great iPhone apps such as Tweetie, be sure to check it out:

iPhone Design Award-Winning Projects (The Definitive Guide)

Comments Off

Postage wins App Gems Award

January 5th, 2010 by Chris
AppGems2009.png

We are pleased to announce that Postage was honored by Macworld with a 2009 App Gems Award! It is just great to be selected among the 20 other winners including standout iPhone apps such as Ramp Champ, Rolando and Tweetie.

As part of winning the award Macworld kindly offered us a kiosk at the 2010 Macworld Expo. Hopefully we will see some of you in San Francisco in February.

You can read about all the winners at Macworld.

2 Comments »