Developing a Calagator Client for the iPhone

iPhone Simulator
Uploaded with plasq‘s Skitch!

I’ve been working on an iPhone app to allow Calagator users to find out what events are happening, get details, and map the event location so they can figure out how to get there. It’s been a little slow going, as this is my first real iPhone development project, but the code is now to the point that the basic feature set is roughly covered.

If you’d like to try it out or contribute, I’ve pushed the code to GitHub, and you can check it out here.

Last week I ran into an issue where I wanted an easy way to strip HTML from a block of text, which is super-simple in Rails, and something I could code up pretty quickly in plain Ruby if needed. Figuring out how to do it in Objective-C was a bit more work, though. Learning a new language, there’s often a tension between how you’re used to approaching a problem, and the tools and preferences of this other language. I did finally come up with something that works and doesn’t feel excessively messy. I started with a snippet from another blog post, but it was crashing when I moved it into my Event model. Below is my solution.

- (NSString *) cleanDescription {
	NSScanner *scanner = [NSScanner scannerWithString:self.description];
	NSString *tag = @"";
	NSString *cleaned = self.description;

	while ([scanner isAtEnd] == NO) {
		[scanner scanUpToString:@"<" intoString:NULL];
		[scanner scanUpToString:@">" intoString:&tag];
		cleaned = [cleaned stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@>", tag] withString:@""];
	}
	return cleaned;
}

Comments are closed.