Thursday, November 4, 2010

Spirit of Nashville iPhone app

The Spirit of Nashville iPhone app is in the App Store here. It's a mobile representation of some of Nashville's most talented artists and video producers. It's also a fun way to get a little Nashville history. Long before we met the design company, Mary and I fell in love with their work and bough two of their posters for our kitchen. When the project started to gel, I was a bit star struck. It's kind of like stringing guitars for one of your favorite bands. I am very honored to have worked with them to build the app.

Sunday, October 17, 2010

Moving Media

I just bought two external USB drives to serve as a mirrored set. Setting up the RAID was easy using Disk Utility. Now I'm copying over iTunes, iPhoto, etc. Here's some handy instructions for iTunes: http://support.apple.com/kb/ht1449

Wednesday, September 22, 2010

WP7 Emulator on Parallels 6 for Mac

I just upgraded to Parallels 6 and thought I would attempt to run the Windows Phone 7 emulator. Simply building and running did not work. However, I ran the emulator from the Start menu. It took a long time for it to start up. The emulator rebooted a few times, then it arrived at the phone home screen. From there, I could launch the debugger from Visual Studio.

While re-testing for this post, I would occasionally see the following error when attempting to attach the debugger:

a specified communication resource (port) is already in use by another application.

I did a Build -> Clean and retried. Success!

The app that I built does nothing. It was simply the Visual Studio template. So I can’t yet attest to performance while debugging, or the availability of features.

The virtual machine is Windows 7 Ultimate. With the first few tests, it had 1 processor and 1GB of ram, which was an error in configuration. I changed it to 2 processors and 4GB of ram. That didn't seem to increase the speed of the emulator startup by very much.

Please give it a try! I am curious if others can reproduce the success.

Thursday, July 22, 2010

Custom tintColor for each segment of UISegmentedControl

The UISegmentedControl offers the ability to set the tint color for the entire control, but it does not offer the ability to set the tint color for an individual segment. In fact, the UISegment class, the actual class for the individual segments, is not publicly documented. So, what I propose here does go a bit off the farm, but it only uses publicly available API to accomplish it. Here is the end result.
The first step is to create an extension to the UISegmentedControl. The extension neatly wraps up the new functionality so that it can be easily reused instead of cluttering up your view controllers.

UISegmentedControlExtension.h
@interface UISegmentedControl(CustomTintExtension)
-(void)setTag:(NSInteger)tag forSegmentAtIndex:(NSUInteger)segment;
-(void)setTintColor:(UIColor*)color forTag:(NSInteger)aTag;
-(void)setTextColor:(UIColor*)color forTag:(NSInteger)aTag;
-(void)setShadowColor:(UIColor*)color forTag:(NSInteger)aTag;
@end

UISegmentedControlExtension.m
#import "UISegmentedControlExtension.h"


@implementation UISegmentedControl(CustomTintExtension)

-(void)setTag:(NSInteger)tag forSegmentAtIndex:(NSUInteger)segment {
[[[self subviews] objectAtIndex:segment] setTag:tag];
}

-(void)setTintColor:(UIColor*)color forTag:(NSInteger)aTag {
// must operate by tags. Subview index is unreliable
UIView *segment = [self viewWithTag:aTag];
SEL tint = @selector(setTintColor:);

// UISegment is an undocumented class, so tread carefully
// if the segment exists and if it responds to the setTintColor message
if (segment && ([segment respondsToSelector:tint])) {
[segment performSelector:tint withObject:color];
}
}

-(void)setTextColor:(UIColor*)color forTag:(NSInteger)aTag {
UIView *segment = [self viewWithTag:aTag];
for (UIView *view in segment.subviews) {
SEL text = @selector(setTextColor:);

// if the sub view exists and if it responds to the setTextColor message
if (view && ([view respondsToSelector:text])) {
[view performSelector:text withObject:color];
}
}
}

-(void)setShadowColor:(UIColor*)color forTag:(NSInteger)aTag {

// you probably know the drill by now
// you could also combine setShadowColor and setTextColor
UIView *segment = [self viewWithTag:aTag];
for (UIView *view in segment.subviews) {
SEL shadowColor = @selector(setShadowColor:);
if (view && ([view respondsToSelector:shadowColor])) {
[view performSelector:shadowColor withObject:color];
}
}
}

@end
Once that is in place, here is an example of a typical UIViewController taking advantage of it.

SegmentColorsViewController.m

#import "SegmentColorsViewController.h"
#import "UISegmentedControlExtension.h"

#define kTagFirst 111
#define kTagSecond 112
#define kTagThird 113

@interface SegmentColorsViewController(PrivateMethods)
-(void)segmentChanged:(id)sender;
-(void)setTextColorsForSegmentedControl:(UISegmentedControl*)segmented;
@end

@implementation SegmentColorsViewController

-(void)viewDidLoad {

// create a simple segmented control
// could have done this in Interface Builder just the same
NSArray *items = [[NSArray alloc] initWithObjects:@"orange", @"yellow", @"green", nil];
UISegmentedControl *colors = [[UISegmentedControl alloc] initWithItems:items];
[items release];
[colors setSegmentedControlStyle:UISegmentedControlStyleBar];
[colors setTintColor:[UIColor lightGrayColor]];
[colors setFrame:CGRectMake(20.0f, 20.0f, 280.0f, 30.0f)];
[colors addTarget:self action:@selector(segmentChanged:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:colors];


// ... now to the interesting bits

// at some point later, the segment indexes change, so
// must set tags on the segments before they render
[colors setTag:kTagFirst forSegmentAtIndex:0];
[colors setTag:kTagSecond forSegmentAtIndex:1];
[colors setTag:kTagThird forSegmentAtIndex:2];

[colors setTintColor:[UIColor orangeColor] forTag:kTagFirst];
[colors setTintColor:[UIColor yellowColor] forTag:kTagSecond];
[colors setTintColor:[UIColor greenColor] forTag:kTagThird];

[self setTextColorsForSegmentedControl:colors];
[colors release];
}

-(void)segmentChanged:(id)sender {
// when a segment is selected, it resets the text colors
// so set them back
[self setTextColorsForSegmentedControl:(UISegmentedControl*)sender];
}

-(void)setTextColorsForSegmentedControl:(UISegmentedControl*)segmented {
[segmented setTextColor:[UIColor yellowColor] forTag:kTagFirst];
[segmented setTextColor:[UIColor blackColor] forTag:kTagSecond];
[segmented setTextColor:[UIColor blueColor] forTag:kTagThird];

[segmented setShadowColor:[UIColor redColor] forTag:kTagFirst];
[segmented setShadowColor:[UIColor whiteColor] forTag:kTagSecond];
[segmented setShadowColor:[UIColor clearColor] forTag:kTagThird];
}
@end



Monday, May 24, 2010

iPhone / iPad Universal Binary notes

Building a universal binary for iPhone / iPad seems a bit unintuitive. Started in XCode by selecting my target, then, in the menu, choose Project -> Upgrade Current Target for iPad…

After that, a build yielded the following warning:

"warning: building for deployment target '3.2' should omit the armv6 architecture."

Select the project, click Info, change the following values:

Base SDK: Optimized (armv6 armv7)
Build Active Architecture Only: NO
Targeted Device Family: iPhone/iPad
iPhone OS Deployment Target: iPhone OS 3.1.3

Should get rid of warning and build and debug on iPad.

When building for the iPhone, don't switch the build target back to 3.1.3. Keep using 3.2.

Tuesday, May 11, 2010

Free Version and in-app purchases

Researching building a free version of an iPhone app and a paid version of the same app that includes in-app purchases.

I got started by copying the target bundle in XCode to create MyApp and MyAppFree. One of my first questions is, how do I handle the bundle id and app id? Found this at StackOverflow that sent me in a slightly different direction:

http://stackoverflow.com/questions/2146097/app-id-and-bundle-seed-id-in-multiple-applications-with-aspn-inapp-purchase-and

particularly:

"…Apple has frowned on having both a "Lite" version as well as an "in-app" updatable version. One or the other. Recently they have been pushing the "in-app" updatable…"

uh oh ... led to this:

http://www.tuaw.com/2009/10/15/apple-relents-in-app-purchase-for-free-apps-allows-demo-to-paid/

So, can have one version of the app instead of free version and full version.

Next read was "App Store Quick Reference: Getting Started with In App Purchase on iPhone OS".
https://developer.apple.com/iphone/news/pdf/in_app_purchase.pdf

http://developer.apple.com/iphone/news/appstoretips/

I read no definitive prohibition against building both a free and an in-app purchase version, but feel that I should be better safe than sorry.


Monday, April 26, 2010

man pages

Today, learning about HTTP Live Streaming for iPhone. Here are a few nuggets that I am picking up along the way.


This tool has several command line tools. Documentation is in man pages. Very awkward to use. Found a way to output man pages to PostScript files: include -t > output file path. So, for instance

man variantplaylistcreator -t > /Users/framewreckuser/Desktop/variantplaylistcreator.ps

Tuesday, April 20, 2010

Pop out to driving directions from your iPhone app

Had do to some discovery today on showing driving directions from inside an iPhone app. I've looked some of this stuff up before, and then didn't take good notes. So, here's my notes and a sample app that I used for testing.

Some good links:

Saturday, April 3, 2010

Uninstall XCode

sudo /Developer/Library/uninstall-devtools --mode=all

Thanks: macdevelopertips.com

Mac OS X System Icons


Mac OS X's system icons are located at

System » Library » CoreServices » CoreTypes.bundle » Contents » Resources