Tuesday, January 24, 2012

Apple: This Hard to Find Evidence Suggests You Should Release iBooks for Mac OS X

Top Free in the Mac App Store
Look at the image on the left of the Top Free apps in the Mac App Store. Notice anything?

Number 1 with a bullet is iBooks Author. Look further down. Number 5 is Kindle. That's like oil and water. You know what would be nice to have as Number 1 or Number 2. iBooks! iBooks Author and iBooks are two tastes that taste great together.

I can think of reasons why Apple might not release iBooks for Mac OS X, but none of them make much sense to me. If Apple wants to take on Amazon and Kindle for eBook supremacy, they have to broaden the reading platform off of just iOS.

I would have bet real money that iBooks for at least Mac OS X was going to be released at the Education event. Clearly I would have lost big.

I'd like to be able to read iBooks on Mac OS X, even if it's just for the occasional reference. Clearly the Mac App Store proves Kindle book readers aren't just reading on their Kindles.

This is What's Wrong with Hollywood: Where are the biggest box office movies (not) streaming?

Take a look at this compilation of the Top 100 movies of 2011 and where they are available (or not) to legally stream from online. This isn't even a complete list as the studios still frequently will only put the standard definition version of a movie up on iTunes when of course an HD copy is available. Also, support for iTunes Extras is nonexistent or weak.

This is why Hollywood is losing money to piracy. There will always be people that just don't want to pay for content, but the big attraction of piracy to honest people is that it feels like everything is available. It's a better service. Seems very analogous to Napster before Apple convinced the music labels to license a very high percentage of their catalogs at reasonable prices for download. Then you have the studios trying to launch their own streaming service, while continuing to cripple the established services out there.

Hollywood has crippled the legal download sites with this quagmire of availability, SD vs. HD, and little to no price break over buying a manufactured physical disc. Clearly the studios are trying to preserve buying physical discs or make at the least make it more enticing than downloading, but it's just not going to happen anymore. The tide has turned. Add to that the complicated "windowing" that studios try to enforce on home viewing rights, and a lot of consumers just check out.

This should be obvious, but don't the studios get that most people can't and won't keep track of the studios windowing schedule? Once you market a movie, if people want to watch that movie and they can't get it legally and at a fair price, at some point they are probably going to investigate pirating because it bypasses all the studio bullshit.

I'm not supporting pirating, but it's not hard to understand the appeal beyond just not paying for stuff.

Friday, January 13, 2012

Thoughts on 44 days of uptime in Mac OS X 10.7 Lion

Decided going into the Martin Luther King, Jr. Day weekend I would actually shutdown day job MacBook Pro instead of sleeping it like I had every other day for who knows how long. I only thought of doing this to save a battery charge & discharge cycle.

I wondered: "How long have I been running this instance of OS X 10.7 Lion?"

44 days was the answer Terminal command uptime gave. The MacBook Pro hadn't booted since November 30, 2011, a whole other year ago! Probably the last time I had powered it off because of Thanksgiving break.

I was kind of shocked for two reasons. I'm usually doing every 2 week beta OS updates or standard updates that require reboots. I skipped the current round because I really wanted to run stable after the OS X 10.7 Lion, Xcode 4.x, iOS 5 beta trifecta over the summer & fall. More surprising though, rebooting OS X has been completely deprecated in my mind as a useful activity unless forced to. To be fair of course, I've quit cycled a few heavy use apps (here's looking at you Xcode) over this stretch. But the system has remained perfectly usable and stable. If not for the holiday, I would have just slept the Mac like I had done before.

What a contrast to the issue I have with Windows 7 on my iMac that would have necessitated some task killing after a few hours if I was really using the OS day to day.

What I'm really curios about is iOS device uptime. I don't ever turn off or reboot my iPhone or iPad except to install a software update.

I marvel at the software engineering!

Wednesday, January 11, 2012

iOS 5 Dev Warning: UITableView's Multiple Select During Editing Doesn't Work with Swipe to Delete

I attended Session 125 - UITableView Changes, Tips, Tricks at WWDC 2011. I also downloaded the video & slides of that session from the WWDC 2011 Session Videos site  (Apple developer account required) .


You can here it in the video, and being in the room, one of the, if not the, favorite moment for developers at the talk was when multiple select during editing was announced. The announcement starts at 16:51 in the talk video.


Jason Beaver immediately shows Apple's Mail application in edit mode. Why? Because that's what every developer and user that has spent any time in Mail want in their apps when editing lists of user content. 


You would expect, given the heavy references to the Mail app and how it works that what regular developers would now have in UITableView is exactly the functionality Mail supports.


But You Would Be Wrong Because Swipe to Delete is Disabled!


If you do this in your code:


self.tableView.allowsMultipleSelectionDuringEditing = YES;



or change the UITableView property in the XIB for Editing to use Multiple Selection During Editing you don't get swipe to delete.


I have no idea if that functionality was planned at WWDC and got dropped during development. The only hint you get swipe to delete won't work in the iOS 5 release documentation is the following on the allowsMultipleSelectionDuringEditing property (emphasis mine):
The default value of this property is NO. If you it to YES, check marks appear next to selected rows in editing mode. In addition, UITableView does not query for editing styles when it goes into editing mode. If you call indexPathsForSelectedRows, you can get the index paths that identify the selected rows.
So if you don't see the docs, or it just doesn't click on first read that this means no swipe to delete, you might do a whole bunch of work for no reason because you need both multiple select during edit and swipe to delete, just...like...Mail.app. I'm only saying this for a friend, of course.


Skeptical? I was too, went through all 7 stages of grief before conclusively proving it. I kept thinking: How could Apple play Lucy with the multiple select football to my Charlie Brown?


Prove it to yourself. Go download Apple's TableMultiSelect sample (Apple developer account required). Open MyTableViewController.m and paste the following three lines in (I pasted after the tableView:cellForRowAtIndexPath: method just to be tidy):



// Override to support conditional editing of the table view.

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath

{

    return YES;

}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 
    return UITableViewCellEditingStyleDelete;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{
    NSLog(@"Commit Editing Style");
}

Run your app in the simulator and true to swipe to delete. It won't work.

Now go to line 74 and comment self.tableView.allowsMultipleSelectionDuringEditing = YES; 

BOOM, you got swipe to delete!

Next Steps
I know, file a radar or GTFO and I will, eventually. I say this not to deride Apple. UITableView is a great piece of UI programming. Whenever designing something of my own, I always ask:
What Would UITableView Do?
I wrote this to warn developers using UITableView's multiple selection functionality at the time of this writing (Xcode 4.2.1 & iOS 5.0.1) is an either or choice with swipe to delete that user's are most likely not going to be happy with. Better to stick with custom implementations unless/until Apple changes the functionality.

Monday, January 09, 2012

Integrating SharePoint with Twitter on a Corporate Intranet

Thankfully I don't have to know how to integrate SharePoint with anything right now, but if I did, I'd know who to turn to for insight.

John DeGiglio is one of the smartest people I know, and one of the most relentless developers I've ever seen. If you give him a problem, he will solve it. John and I used to write .Net apps together, and he specialized in  SharePoint. He's become an expert over the last 5 or so years.

John's recently published his first public blog articles and CodePlex projects on integrating Twitter with SharePoint. 


How this WebPart came together is documented in two blog posts hosted by Synergy Online:

John's also restarted his blog Backhand Volley at DeGiglio.biz. Unfortunately some good content was lost when Microsoft shutdown MSN/Windows Live Spaces. He didn't get the notification from MS to download his content before it was deleted.

John's also on Twitter @jdegiglio and his Tweets just went public! I expect more SharePoint or tennis focused tweets, John's a huge tennis fan.

Saturday, December 31, 2011

Retro Review: Mass Effect 2. Why Can't I Play Like Captain Kirk?

I finished Mass Effect 2 around June 2011. I played the game from the start with several pieces of DLC installed on the Xbox 360. I didn't have "Lair of the Shadow Broker" installed, nor did I ever get it. Overall, this was a very good game. I look forward to playing Mass Effect 3 in early 2012. 

The good parts of Mass Effect 2 were great. Voice acting is fantastic. Combat was streamlined from Mass Effect 1 making it excellent. The RPG part was also streamlined, eliminating a lot of the busywork from ME1 without losing the customizability.

What I expect from the Mass Effect series is an adult science fiction game. Why then is Commander Shepard limited to such puritanical sexual relationships? I want to play my Commander Shepard like Captain Kirk, sleeping with every available crew member or mission encountered alien that I can! Instead, what I get in Mass Effect is a very linear and monogamous relationship system only on ship were all the potential romantic participants are apparently talking to each other. It's just like High School. Downloadable character Kasumi's only ship function appears to be relationship gossip. The main characters all never appear to leave their assigned ship rooms, yet everyone knows everybody's business! Other than Kelly, all other characters are prudes. If I had to hear Jacob Taylor say "Let's not push it, we got a good thing going here Shepard" one more time, I would've thrown my controller at the Xbox. The system is to on rails.

What I would do if I were designing the game is to leave all sexual relationship options available at all times, just make those decisions tie to paragon/renegade points. If Shepard has already started sleeping with a character, and then tried to pick up another lover, that choice could feed into the complexity of your character more completely. Play with the highest honor on the battlefield, but be a total dog with your crew, or vice versa. I even have a problem assigning renegade points to a Shepard that sleeps around, but within the design of the game doing that would be the cleanest "fix". Also each character could have different relationship needs to achieve their highest morale. In ME2, all potential romantic characters appear to have the same end need, a monogamous relationship with Shepard. Again, Kelly excepted, but even she won't continue or start a relationship with Shepard if Shepard has already started something with another character, and she's the "slut" of the ship.

I look forward to the day when I can play as a character in a game that was as open as Captain Kirk over 40 years ago.

Friday, December 23, 2011

How I Came to Loathe the Nintendo Wii, and it's Microsoft's Fault!

I loved the Nintendo Wii when I got it back in 2007. When I looked up my review, I couldn't believe it had been over 4 years already. LIke pretty much everyone, I played Super Mario Galaxy & thought that was great too. My family had a lot of fun with Wii Sports and Wii Sports Resort over the years. Slowly but surely, my initial love for Nintendo's console grew to dislike, then outright loathing. There wasn't a moment of clarity when I realized I never wanted to use the Wii again. It was a gradual process and it was Microsoft's fault!

After a few years with thr Wii, I was completely over the four part Wii controllers: remote, nun-chuck, rubber bumper, and motion plus. The batteries for the remotes were never charged. The nun-chuck wire always got tangled. The rubber bumpers to make sure you didn't kill someone flailing around we're never in the configuration you needed to play what you wanted to. Worse, no one but me, not the kids and not the wife, could untangle the whole mess. The fact that Nintendo didn't ship the controllers as rechargeable became a deal breaker, even though I was using rechargeable batteries. 

I couldn't pin down what i didnt like about thr Wii until I first heard about the Kinect. A bit flipped in my head right then that I was done with the Wii if Microsoft didn't mess it up. I didnt want to use a controller for motion controls ever again. Amazingly, Microsoft got it right, not perfect, but good enough from all the stuff I read. I didn't rush out to buy Kinect. I waited for a while to get some more life out of the replacement Xbox 360 I got from the Red Ring of Death fiasco. That I even considered giving Microsoft more money was amazing, they were all but dead to me before Kinect was announced. Going back to Microsoft was also given a boost by Sony announcing their Wii competitor, Move, packing its own fleet or wand/remote controllers. 

The announcement of the Nintendo Wii U and Sony's PlayStation Network security breach happened within a few weeks of each other in May/June 2011. Those events were the tipping point to Kinect for me. Wii U looks ridiculous. I normally hold out on judging a product until release, but I couldn't suppress an immediate reaction of disappointment. Wii U looks like an iPad and Apple TV using AirPlay, but without a good digital download store. Sony's ridiculous lack of network penetration testing and basic security controls were inexcusable. 

By August I had sold my Wii and replacement Xbox 360 at a yard sale to finance the purchase of a new Xbox with Kinect. I was going to sell the PlayStation 3 as well, but Uncharted 3 and a few unripped Blu-rays have caused a delay.

As for the Kinect itself, pretty awesome. Demonstrably better than the Wii for exercise games, which I've used but my wife really enjoys. And in extended Kinect Adventures sessions, no Wii remote like cramping or fatigue, just normal exercise pains. Having the ability to video chat is nice too, though it is odd that it isn't in HD. With Christmas days away, a bunch more Kinect titles are coming home, I'm sure the whole family is going to be having a lot of fun.

Wednesday, November 09, 2011

There Must Be A Glitch In The Matrix Because I Just Perfectly Experienced Programming Serendipity

Sunk a lot of time researching and then trying to implement Mac OS X application sandboxing today, only to strike out. While watching one of the WWDC 2011 sandboxing videos for the third time, I saw Apple Events mentioned in the presentation. Slowly realized I was looking at the clue I needed to unravel a feature for SleepMute that I've poured many man-days of research into. With that clue, the rough version of this new feature was done in 40 minutes!

If that's not programming serendipity, I don't know what it is.

Tuesday, October 18, 2011

Implementing Objective-C Protocol Inheritance, Usually For Delegates

In a previous post, I explained why an Objective-C protocol might not implement respondToSelector:. Prior to Xcode 4.x, Apple's protocol template code didn't include the <NSObject> protocol in custom protocol definitions. This let to believe that you couldn't setup inheritance chains for protocols, but but you can!

This is usually important where you have a UIView subclass that's the base class for a bunch of subclasses. All instances must support the same message back to a delegate pattern, but subclasses might need to add more delegate callbacks than the base class should define.

Consider this class & protocol definition & class implementation:

@class VehicleView;

@protocol VehicleViewDelegate <NSObject>
- (void)vehicleView:(VehicleView *)vehicleView didTapToStartEngine:(Engine *)engine;

@optional
- (void)vehicleView:(VehicleView *)vehicleView didTapToOpenWindow:(VehicleWindow *)vehicleWindow;

@end

@interface VehicleView : NSObject {
 id<VehicleViewDelegate> _delegate;
 NSArray *_engines;
 NSArray *_vehicleWindows;
}

@property (non atomic, assign) id<VehicleViewDelegate> delegate;
@property (nonatomic, retain) NSArray *engines;
@property (nonatomic, retain) NSArray *vehiclesWindows;

@end

Now the implementation

@implementation VehicleView

@synthesize delegate = _delegate, engines = _engines, vehicleWindows = _vehicleWindows;

//Lots of other stuff to implement!

@end

What you can see there is a pretty typical class implementing a protocol then declaring a delegate instance variable and property pattern. But what does this look like when we want to subclass?

@class TruckView;

@protocol TruckViewDelegate <VehicleViewDelegate>

@optional
- (void)trunkView:(TruckView *)truckView didTapUseFourByFourMode;

@end

@interface TruckView: VehicleVIew {
}

//Subclass specific implementation

@end

Notice there's no delegate definition, what gives? That's true, but we are going to reuse our base class' instance variable for this:

@implementation TruckView

#pragma mark - Properties

- (id<TruckViewDelegate>)delegate
{
 return _delegate;
}

- (void)setDelegate:(id<TruckViewDelegate>)delegate
{
 if(_delegate != delegate) {
  _delegate = delegate;
 }
}

@end

So what's going on? The TruckView subclass overrode VehicleView's syntactic sugar property method declarations for delegate with the protocol definition that it wanted, but reused the base class instance variable. This allows TruckView to verify it has a pointer which implements the protocol, eliminates any dual-protocol declarations and management in TruckView, and maximizes protocol definition reuse.

Next time, I'll show how to optimize detection of @optional protocol methods so setting up @protocol inheritance hierarchies don't slow down performance.

Monday, October 10, 2011

A Tale of Computing Misery: How To Fix Seagate GoFlex External Drives Randomly Ejecting in Mac OS X 10.7 Lion

I don't know if I'll ever buy another Seagate drive. This is a tale of 3 months of computing misery.

Rewind

When I saw the news back in early July that Mac OS X 10.7 Lion had hit Gold Master (GM), the expected release to paying customers, I immediately downloaded and installed on my main machine, an iMac.

A few days later, I filed Radar 9727925 (OpenRadar link). Lion was randomly automatically ejecting my external Seagate HD. This had never happened under any version of OS X 10.6 Snow Leopard. I had all my code on this drive, the iMac's internal drive was near full, as well as a ton of media files I keep the Apple TV feed with. Also, all my photos were on this drive. I figured it was an obvious bug, some bizarre oversight, and should definitely get fixed. I thought it was bad enough that 10.7.0 would get the dubious distinction of needing GM2.

That didn't happen. 10.7.0 shipped as expected, and my external disk keep ejecting with a scary modal error dialog like clockwork. I was frustrated. My excitement for Lion was high coming back from WWDC 2011, but I had staid my hand on the primary machine until the OS reached GM. Of course, I had installed to a different external drive to do testing, and it was great on my iMac, I thought I was home free.

But I couldn't have been more wrong about Lion, or at least I thought for three months…

The Long Wait

After filing my bug, Apple responded before 10.7.0 shipping asking me to run a disk-debug command and capture the trace of what happened during the random ejection. I collected the information and supplied it to Apple. I eagerly awaited a response, but none came.

I installed 10.7.1 as soon as it came out, hopeful my bug would be stealth resolved. It wasn't and I grew despondent. How could Apple leave this bug unfixed? I searched the Apple Support Communities. Clearly other people were affected by this. This was the worst Mac OS X bug I had experienced since I started using it with 10.3.x.

As soon as the first 10.7.2 builds started arriving in the Mac developer center, I deployed it. The iMac I am putting this on is the whole house iTunes media server, I was risking wife and kid wrath making this move. They do not tolerate beta. Early 10.7.2 betas didn't resolve the bug. I started to panic. Could 10.7.2 make it through development without this issue getting fixed?

Desperation

If you've ever been to an Apple developer event, you know they say if you have any questions just email them. I've always admired that, and wouldn't know if I would feel comfortable if I were in those shoes encouraging public emails for help.

On August 30, 2011, I emailed Michael Jurewitz out of desperation:

Hi Mike,

Can you figure out what the real status is of Radar 9727925? In short, the external drive where I keep a huge chunk of my files, including my code, keeps randomly ejecting a dozen or more times a day. Never happened in Snow Leopard.

I hated to even think to ask you, but I filed this bug close to 3 months ago and it's driving me crazy. 

If anything it's gotten worse in the latest 10.7.2 seed. Yes I am on the bleeding edge hoping this one bug gets fixed.

Thanks so much, Dave

I couldn't stand sending that email. I just about cried when I got the automated Out of Office reply. What was I going to do now? I remembered that I could email Apple and ask for a status update on the bug. I did that and hoped for the best, but I couldn't take it anymore, time to start deep debugging to prove whether it was anything specific to my environment.

Taking Matters Into My Own Hands

Deep Debugging OS X is really not that complicated. Here's the rough outline:

  1. Verify your System disk for any corruption
  2. Repair Disk Permissions
  3. Create a new user account and see if you can reproduce the bug
  4. Install a new copy of the current OS on an internal disk partition and see if you can reproduce the bug
  5. Remove anything 3rd party that starts up with the OS one at a time until the bug stops such as:
    • StartupItems
    • LoginItems
    • LaunchAgents
    • LaunchDaemons
    • Kernel Extensions (.kexts)
  6. File a Radar or GTFO
I had started with number 6 because the bug seemed real clear. I installed Lion, external disk started randomly ejecting, case closed it's an OS bug!

But I started going through the whole debugging sequence just to be extra double sure this wasn't specific to my environment. I executed steps 1-4 and reproduced the bug. I was even more certain this had to be a Lion bug. With a bare OS X install, the external disk was randomly ejecting. This is the smoking gun right? Wrong!

I went through all the 3rd party code in step 5 that was loading on my system. Something interesting caught my eye. Lion wasn't loading some Seagate kernel extensions since they didn't include 64-bit versions. I went out to Seagate's site, and found GoFlex for Mac 1.1.2, but I didn't install it. Normally when debugging something, you try and remove 3rd party stuff to fix a problem, you don't add it back in. Besides, when I skimmed the description of this software, the usefulness of the package seemed limited to Drive Settings and Diagnostics, the only capitalized words in the summary that weren't MacOS or GoFlex. I'm sure I was trying to figure this out one night bleary eyed well past midnight, so I was probably in a hurry due to exhaustion and didn't feel like reading the paragraph, my mistake! I put the problem on hold for a few more days.

The Workaround

A few days go by, I install the latest 10.7.2 beta without it resolving the bug, I brainstorm on what it could be. During one of these sessions, it dawned on me that it looks like the drive is getting ejected if it's not being used. There is some kind of sleep timer being fired! I check the Energy Saver System Preference, but Put the hard disk(s) to sleep when possible is unchecked. This must be where the bug is, Lion is always sleeping the drive when possible but there is some incompatibility, thus the modal error dialog I reasoned.

I hadn't really done much with Automator, but I figured this was the kind of thing it might be good at. I whipped up a quick workflow app that did a search for a string in file names on the external drive, and had it open as a LoginItem. Voila! The external drive stopped ejecting! It was a sleep timer. The relief was immediate, it was like I just scored a touchdown, or for the non-sports inclined, like I had just solved an incredibly difficult puzzle. I could wait as long as it took for Apple to fix this Lion bug now, I wasn't really impacted anymore and I stopped thinking about it. Only it wasn't a Lion bug at all, not really.

Finally, The Solution

On October 3, 2011, Apple responds to my request for more information on the bug. I don't know if Michael Jurewitz was the invisible hand that got this moving, or it was just my place in the request for info queue, but I was excited when I received the mail. I paraphrase because of NDA restrictions. The message thanks me for my patience and told me that to fix the issue I must install GoFlex for Mac 1.1.2! How is it possible that to use a USB or FireWire (the GoFlex does both, reason I bought it) in OS X Lion you need 3rd party software? I then went back to the Seagate site and read the description of this software again, and it hit me like a shot of vodka:

drivers to disable the built-in sleep timer on the drive
I was floored, and both right and oh so wrong. It was a sleep timer, but I was digging in the wrong place! I'm sorry Lion and Apple, you weren't at fault. Why would Seagate build something like this into the drive? I can understand building in a lower power mode, but not one that causes the second more popular consumer operating system in the world to flat out not work without an otherwise useless driver. Worse, there are at least three pieces of code launching in OS X at startup that are from Seagate, but none are any kind of automatic update. I bought this drive in 2010, it's not a holdover from the Windows 95 era! Automatic update is table stakes for anyone shipping software, even more so on Apple products. Either you ship your apps through the App Store which gives you automatic update for free, you roll your own, or GTFO! All I wanted was external storage that just worked with OS X, instead I've acquired another piece of crap recurring task like I had to poll the Dell site in '95 for updated drivers. Greeaattt!, I've added an event to iCal and made this a WebClip in Dashboard, my first!