Categories
Development

A change in coding style

I’m a verbose guy when it comes to code. The compiler doesn’t care and it’s easier for me to read later on down the road. I’ve changed my style over the past few months, it started at Pelco because I was confusing folks with a particular syntax. I must admit, it even confused me on occasion.

When checking pointers I used to do this.

if (NULL != ptr)

That was confusing. I’ve since switched my tune back to a tried and true method of removing the NULL !=, like this

if (ptr)

Much easier for most to understand. I do, however, still check for explicit FALSE and NULL as the case may be, because I believe it to be a bit more clear. Here’s what that looks like.

if (NULL == ptr)

or

if (FALSE == value)

There is a statement some don’t like, that I love, and probably won’t switch away from. The ternary operator.

something = (value) ? value1 : value2;

My brain just likes it.

Categories
Development Uncategorized

Using P8, the ping.fm Objective-C engine

I just wanted to test a code highlighter plugin for WordPress, so I’ll use my open source ping.fm Objective-C engine as an example. Yeah, I know, shameless self promotion.

Here’s how to use P8 in your app…

[codesyntax lang=”objc”]

// Yes, you owe a Release later for P8 and
// TestDelegate. This example doesn't do it.
TestDelegate* del = [[TestDelegate alloc] init];
P8Engine* P8 = [[P8Engine alloc] initWithOptions:kP8APIKey appKey:kP8AppKey delegate:del];
if (nil != P8)
{
	// Post something.
	[P8 userPostStatus:@"Testing 1,2,3... Please ignore, http://f67.us/iam"];

	// Create a short URL
	[P8 urlCreate:@"http://rob.crabapples.net/"];

	// Resolve a short URL
	[P8 urlResolve:@"http://ping.fm/xeECl"];
}

[/codesyntax]

Ok, I don’t really like that.

Categories
Development

Best comments in code

I was pointed to this great thread on StackOverflow about comments in code and instantly thought of a comment I ran across in one of our test tools codebase. Since I couldn’t add it to the StackOverflow thread, I’ll post it here for your enjoyment.

			////           I GIVE UP!
			////
			////             ___________.._______
			////| .__________))______|
			////| | / /      ||
			////| |/ /       ||
			////| | /        ||.-''.
			////| |/         |/  _  \
			////| |          ||  `/,|
			////| |          (\\`_.'
			////| |         .-`--'.
			////| |        /Y . . Y\
			////| |       // |   | \\
			////| |      //  | . |  \\
			////| |     ')   |   |   (`
			////| |          ||'||
			////| |          || ||
			////| |          || ||
			////| |          || ||
			////| |         / | | \
			////| |
			////| |
			////| |
			////| |
			////| |
Categories
Development

Objective-C: Don’t make this mistake

Duct Tape, fixer of all things!It’s the little things that can drive a developer to jumping out a window. You plan a solution, code the solution, build the solution, run it, and… it doesn’t work. Most of the time you spot the problem right away, some times you’re left scratching your head, repeating over and over “this looks like it should work?” Of course you know better. It didn’t work, you just can’t see why. I had this problem last night so I thought I’d share with the world, ok not the world, just my electronic brain, so I can look it up later if necessary.

Here’s what I did.

@protocol Blah<NSObject>
-(void)somethingHappened
-(void)somethingElse
@end

Then I implemented the protocol.

@interface NeatoStuff : OtherStuff<Blah>
...
@end

Later, in a different hunk of code I want to send a message to that implementation, so I did something I’ve now done many, many, times. I check to see if the delegate I’ve been given actually answers the message(implements the method) I’d like to send.

SEL delegateSelector = @selector(somethingHappened:);
if ([_delegate respondsToSelector:delegateSelector]) 
{ 
    [_delegate performSelector:delegateSelector];
}

It didn’t work, and I couldn’t see why. Can you? I’ll wait, go ahead and look it over again, I’ll play some Jeopardy music while you work.

Did you spot the problem? It’s one little character. This…

SEL delegateSelector = @selector(somethingHappened:);

Should be this…

SEL delegateSelector = @selector(somethingHappened);

Yep, that’s it. One little “:” had me pulling my hair out, and I just couldn’t see the problem to save my life, at least not for about 10-minutes of outright frustration.

The message doesn’t expect to receive arguments, so the “:” is not necessary. Note to self: Don’t do that again.

Categories
Development Indie iPhone

Successful non-game iPhone App

TapTapTap Blog: “How do you launch an iPhone app that’s not a game and have it succeed? It’s definitely not easy, given the current atmosphere of the App Store. But we recently did with our app, Camera+, and it’s gone on to be our most successful launch to date, earning over a quarter million dollars in its first month.

Hats off! Emphasis above is mine. WOW, that’s quite a month.

Categories
Development iPhone

The little language that could

Ansca Mobile Blog: “In the past few days, thousands of developers have been dissecting the application bundles of top-selling App Store games. What they found was that many top-selling apps embed Lua, such as the top-5 selling app Diner Dash (which has an entire folder of uncompiled Lua script files, i.e. the raw source, inside the application bundle) and the international #1 selling app Angry Birds (which also contains multiple .lua files) just to name a few. Even Tapulous’ #1-selling family of Tap Tap Revenge apps — perhaps the most well-known apps in the history of the iPhone App Store and featured onstage by Steve Jobs himself at the OS 4.0 launch — embed Lua.”

If you’re a developer looking for a nice cross platform scripting language, Lua may do the trick.

Even Adobe’s heaving hitting Lightroom is partially Lua, that’s saying something.

If you’re a Mac, or iPhone, or iPad developer, check out Gus Mueller’s wrapper around Lua, LuaCore.

Categories
Development

Say Goodbye to Flash

Campaign Monitor: “The beautiful thing about moving to a JavaScript based solution is that, unlike the closed Flash component, we had complete control over every bit of the charts. This meant we could easily add features we felt were missing from the default charts and offer a really nice experience for you and your clients. Here are some of the more interesting extras we added to the base library:”

I like stuff like this, a real world example that makes sense.

Categories
Development Indie Mac

Pay it forward

A wonderful bouquet of flowers.Mac Indie: “One of my primary goals in starting MacInde last year was to catalog and recognize all the tools that are available to Indie Mac/iPhone developers that can make your development life easier, faster, more efficient, etc. I’ll bet that if you tried to re-create all of the production quality code out there that we’re all using in our OSX and iPhoneOS apps thanks to this community, there’s probably 5-7 man-years of effort that you’d need to spend in doing it.”

Support your local Mac Indie! There’s a lot of really great free, and open source, Mac/iPhone/iPad source code floating around out there. Help these guys out if you can. I know I need to.

Shameless self promotion: Need Objective-C/Cocoa code to shorten a URL, or communicate with ping.fm, click here.

NOTE: I haven’t built that code in a LONG time, in fact, I haven’t built it for Mac since upgrading to Snow Leopard. It built without error for iPhone OS and Mac OS X the last time I did build it. Your mileage may vary. I definitely need to spend some quality time with it.

Categories
Apple Development iPad iPhone

We ❤ Choice

Adobe: “We believe open markets that allow developers, publishers, and consumers to make their own choices about how they create, distribute, and access content are essential to progress. That’s why we actively support technologies like HTML4, HTML5, CSS, and H.264, in addition to our own technologies.”

I love Adobe, and Adobe products, but… and there’s always a but, the article talks about openness and freedom, and yes all those technologies called out are open, but I still don’t get the article.

It’s about freedom, right? Here’s a fact for you. Developers have the freedom to choose to develop for the iPhone, iPod Touch, and iPad by choosing to use Apple’s development tools. They also have the freedom to choose to not use those tools and not develop for the platform.

I don’t get it guys, I really don’t.

Flash changed the web experience, admit it. Like other technologies before it, it opened the door, opened eyes, and led to a new standard that is poised to supplant it.

The other thing you have to remember is Adobe can run Flash on a bazillion other platforms. If those platforms, running Flash, start to outsell, or cause Apple to start losing market share, they’ll change their tune.

The Free FreeHand folks have something to say about freedom.

Categories
Business Development Life

NY: Help Wanted, Coders

Matt Mireles: “New York City has a shortage of entrepreneurially minded technical talent. It’s not that there’s not enough engineers. Hardly. Columbia, NYU and the rest of the eastern seaboard spits out engineers in spades each year. But somehow those aren’t funneled into, aware of or interested in the NYC startups, at least at the early stage. Local engineers, it seems, want to be employees, not co-founders.”

I’d imagine a lot of kids just out of school would like to learn a bit about the business before they venture out on their own. Maybe they’re interested in working for one of the biggies; Apple, Microsoft, Google, or maybe they’d like to work for one of New York’s own exciting startups like Tumblr, those guys are kicking some major butt at the moment.

It is interesting to see this happening in New York City.