This post is for anyone else out there that may run into this problem. I created a custom storyboard segue to dismiss a view controller presented modally.

My custom segue code is extremely simple:

import Foundation
import UIKit

class DissmissSegue : UIStoryboardSegue {

   override func perform() {
      if let viewController = self.sourceViewController as? UIViewController {
         viewController.presentingViewController?.dismissViewControllerAnimated(true) { }
      }
   }

}

Correspondingly, the storyboard looks something like this:

Custom segues

The image above shows the two custom segues circled in red. When either the Done or Cancel buttons are pressed the modal should be dismissed. However, I kept experiencing a crash when either button was pressed. Logically, I put breakpoints in my code in an attempt to figure out what was happening.

Turns out my custom perform method was never getting called. This was a bit of a head scratcher and it took a bit of time to figure it out. If you are seeing this issue make sure your segue is specifying which Segue Module to use in the inspector pane of the storyboard.

Screen shot 2015 01 11 at 7.11.47 pm

I lost time tracking down a bug in a text parser I wrote due to unexpected behavior in an NSString method. My parser leverages enumerateSubstringsInRange:options:usingBlock: with the NSStringEnumerationBySentences option to tokenize sentences. Each sentence gets placed into a dictionary keyed by the sentence index.

Somehow my tests pass, but parsing fails on user inputted text. It took longer than it should have to track down the bug, but I realized the source of the issue is due to capitalization. I was able to verify the problem with following two tests. The first test passes, while the second fails miserably. I opened an issue with Apple to track the problem. I am hopeful Apple will release a fix soon. In the meantime I am going to workaround the limitation by taking the regular expression route.

Passes:

- (void)testEnumerateString1 {
   NSMutableArray *sentences = [NSMutableArray array];
   NSString *string = @"I need to do something at 1pm. This is a second sentence";
   NSRange range = NSMakeRange(0, [string length]);

   [string enumerateSubstringsInRange:range
                              options:NSStringEnumerationBySentences
                           usingBlock:^(NSString *substring,
                                        NSRange substringRange,
                                        NSRange enclosingRange,
                                        BOOL *stop) {
      [sentences addObject:substring];
   }];

   // Test passes
   XCTAssertEqual([sentences count], (NSUInteger)2, @"there should be two sentences");
}

Fails:

- (void)testEnumerateString2 {
   NSMutableArray *sentences = [NSMutableArray array];
   NSString *string = @"I need to do something at 1pm. this is a second sentence";
   NSRange range = NSMakeRange(0, [string length]);

   [string enumerateSubstringsInRange:range
                              options:NSStringEnumerationBySentences
                           usingBlock:^(NSString *substring,
                                        NSRange substringRange,
                                        NSRange enclosingRange,
                                        BOOL *stop) {
      [sentences addObject:substring];
   }];

   // Test fails
   XCTAssertEqual([sentences count], (NSUInteger)2, @"there should be two sentences");
}
April 15, 2014

Chantilly Circuit Race

Chantilly was a standard, boring office park circuit race. The road surface did not fare the winter well. The back side of the course was a minefield of broken pavement, seams, and sand. On each lap there was a lot of jostling for position in the field. Everyone wanted to be towards the front to avoid plowing unseen into a pothole.

DC Velo, NCVC, and Bike Doctor were well represented, again. Each team had their motivations for a sprint finish, so any efforts to get away fizzled out within a lap or two. A stiff headwind coming into the finishing stretch teased at the possibility of a breakaway. For those of us not interested in a sprint, there was a possibility to get away, or at least attempt to.

I think it was with 5 to go, a group of maybe eight guys snuck off the front. I worked my way across the gap and when I got there I kept going. They sat up to look at one another, so I took off. A few other guys came with me. We were able to grow the gap a little further, but a lack of cooperation, motivation, and the headwind put an end to the move. That was pretty much it for my race at that point.

The Good

  • Kept myself in a position to make moves
  • Felt like a race protagonist

The Bad

  • Wasted effort chasing moves
  • Should have conserved for the eventual sprint
  • Put myself in a bad position going into final corner
  • Didn't contest sprint

Result

Safe, in the pack

April 14, 2014

Carl Dolan

I have a love / hate relationship with this race. I have done well here in the past, I have also had unremarkable placings. As always, there was a strong headwind coming from the direction of the start/finish line. The headwind served to slow the efforts of the pack each time up the hill. Because of this, the race was never spirited enough for it to be hard.

A large group managed to split from the front of the field with 13 laps to go. The field managed to keep the gap to less than 10 seconds. Right as I began to debate crossing the gap the officials neutralized the field. A gust of wind knocked the timing gate over onto a spectator. We waited for the officials to move the gate and resume racing. The delay caused by the accident took 4 laps off the race.

My legs felt like wood for half of the lap after we resumed racing. Renewed motivation after the neutralization brought the two groups back together. I sat in the field until the last lap. Leading into the last lap, I thought hard about where I wanted to position myself for the last corner. It's funny that I was so focused on positioning into the corner that I neglected to plan my sprint for the line.

With 400 meters to go I found myself sitting in a great position on the back of the DC Velo sprint train. As we began to crest the hill, the train slowed. At a point where I should have been patient, I went for it. It was way too far out, running out of steam shy of the line. Next year I need to wait longer.

Bliummxiaaaac4e

The Good

  • Sat in, didn't do any extra work
  • I feel like my race confidence has returned
  • Could go anywhere in the pack I wanted, even on last lap
  • Race felt really easy

The Bad

  • I rode a smart race until 300m to go, then blew it
  • Need to mentally mark sprint point

Result

Safe, in the pack

April 8, 2014

All American Road Race

Weather reports called for a high near 60, but I don't think it ever made it past 52. Clothing choice was difficult, a strong wind made it feel even colder than it was. I made the wrong decision to wear heavy gloves and arm warmers. Once warmed up, they were too much, I definitely roasted myself.

The first lap was hectic. DC Velo, Bike Doctor, and Harley were all well represented. Accordingly they each took turns sending guys off the front. I wasted a lot of energy throughout the first two laps chasing futile moves. Each move was too early for it to stick, and I knew that. Despite that, I chased anyway.

It seems there is always a crash within the first two laps of this race. This year was no different. The field turned into the crosswind on River road. Somewhere behind me there was a touch of wheels, a crash, and a split in the field. The split was short lived, but it did manage two things: first, it weakened the field. Guys chased hard to get back on, and second it reduced the size of some of the bigger teams.

Blood was in the water. People were tiring just as we started the third lap. I was sitting somewhere within the top 15 after making the turn onto Sugarland road. We rolled through the first couple sections and I spotted a group of 8, or 9 guys moving into the distance. Somewhere they had gone off the front. That was the move.

I waited for the right opportunity, and jumped from the field, going through the inside of a turn to get a decent gap. Out of the saddle, I pushed hard across the gap to the break. It felt like a good minute of all-out effort, but I made it. Once there, the things I should have done, and the things I did are not congruent.

The effort of bridging the gap put me into the hole. It took a while to settle into a good rhythm. Also, I was not attentive to eating, or drinking. I should have eaten/drank something on the first lap of the break. By the time it occurred to me that I was running low, it was already way too late. I spent almost 5 laps in the break before I completely exploded. The field rolled by, but that was it for me.

I was two laps short, and that was the winning move. I am happy that I picked the winning move, but unhappy that I did not take better care of my interests.

The Good

  • Good positioning
  • Read the race correctly
  • Made the winning move

The Bad

  • Wasted too much energy the first to laps
  • Didn't eat, or drink enough before the race
  • Didn't eat, or drink enough during the race
  • Need thicker skin when it comes to putting all eggs in one basket

Result

DNF