but don’t let it know who you are… they never forget…

First time to a new venue, Maverick’s at the Jacksonville Landing

MAVERICKS Rock N’ Honky Tonk to use it’s full name. It used to be a “Club Paris”, which is quite a grand departure, like that one Wachowski brother that became a sister, still they wrote a few good movies.

Side note on the Maverick’s web site, from a web developer (geek) perspective. First and foremost, the mute button is at the top center of the page, I hate any site that plays a/v upon entry, seriously, WTF? If I’m going to wake someone up during a late night web browsing session it better be with porn, not a commercial that sounds like it’s from a locally owned and operated plywood store, at least with the porn I get to feel like a man, and possibly feel like an incredibly lucky man playing “alright, our turn” with a pretty lady (do you think writing stuff like that down makes it more or less likely to happen again?). By the way,this is a commercial from a locally owned and operated plywood store, which actually ended up on an episode of Tosh.0… so that’s, …something. What are we talking about again? Oh yes, other than that wholly unacceptable audio playing when you enter the site this is actually one of the better concert venue sites I’ve seen. They have clear navigation, the pages don’t have tons of non-related content on them and the theme is consistent and not over-done. To put that in perspective, here’s the site of the venue I frequent the most, no useful navigation, a theme that is a cleaner version of the one on their original site (which no longer exists) and a link to a Facebook page with even more useless info on it, hooray for not trying!

Back to the music, Cage The Elephant, Tank You Happy Birthday tour. This is one of those bands you really want to see live (and in a small venue) if you can. An energetic frontman and a band with passion. Their sound is hard to define as they have several different sounds, that all somehow seem to go together and remain them. They have songs that remind me of The White Stripes, The Strokes and Nirvana, while not sounding exactly like any of them. Here’s one of their current singles, Shake Me Down:

You may have noticed that I don’t have a clip of the opening band here. Well, that’s because they sounded like an average band of a type of music I don’t listen to. What type is that you ask (I’m sure at least one person reading this asked that [what do you mean no one reads this? Eff you inner voice!])? Semi-hard constantly rhythmic moaning rock, like if you took the parts of Pearl Jam where he isn’t really singing words, but making long drawn out noises (ooooohOHOhohOhHHHHOooohooohOHOHoooooo, the man has serious lung capacity) and made an entire song out of that with average music backing it. That being said they really didn’t suck, just not my cup of tea. O’Brother is this band. Cage The Elephant is the band though, and they went out with that old-school grunge/punk rock feel, guitar toss and all (because slamming your guitar down is for drug-addicted rock and roll stars where as tossing your guitar almost nonchalantly is for disillusioned soulful alt-rockers [or dude realized the beer we were drinking out of the type of cups people hand to runners during marathons cost $4 a pop]):

Next Time Gadget… peace.


so you wanna have cleaner code eh?

Making a helper class, because, you know… it’s helpful

You only need one class implementing the delegate methods and handling the objects related to NSURLConnection, after all who wants to bloat their controllers that make these calls with this repetitive code? No one, we like clean code that’s crisp and comforting, not unlike clean sheets or underwear. So what’s needed for this helper class? Well, a class file, extending NSObject that implements the NSURLConnection delegate and has the necessary objects, like NSData. And you’ll want to implement at the very least the three delegate methods you would implement in your view controller, if your were making this call there. (If you have no idea what these are look here:more specifically here, or Google it, there are many code examples of these methods).

Simple, /cheer. Your helper class now has the methods in it that would have otherwise existed in one of your view controllers. But this is obviously not enough, for one thing, how are you supposed to call this? Well that’s simple, you can’t! Not until you create a method in this helper that takes in the needed data. What is our needed data though? Let’s keep things simple and say we only need a NSURLRequest, which means you built this in your view controller from some NSURL and it already has any post parameters you may want, and we need a hook, something that can be used to let our controller know once the connection is complete and the data is ready for use, a callback string. If this is the case you may now have a method in your helper with a signature that looks something like:

– (void)makeConnectionWithRequest:(NSURLRequest *)theRequest andCallback:(NSString *)theCallback;

It is this method where you will now be making your request, as opposed to your view controller’s method for a button press (or in viewDidLoad, or wherever you were previously making it), and in this method where you will set the connection helper’s call back property (so you know, you should make sure your connection helper has a NSString for this property).

Last, but not least, we have one more thing to consider in this helper class, and that is actually utilizing this call back value. Normally in your connectionDidFinishLoading implementation you would do whatever it is you want to do with your data. Well this is still true, but what we want to do is now slightly different. We want to take this response data and put it in a dictionary (because NSDictionary objects are the shit) that we pass back to the view controller via a NSNotification, using that call back string we have. This leads us to the next part of this wonderful world of clean code.

Listening for NSNotifications so we can act on our data, once we have it that is

You should listen for things in the view controller asking for this data by registering for the notification you care about, which will have the same call back name we’ve been talking about. (If this idea is new to you look at this:hooray this or some other Google result, this happened to be the first one). When registering for this notification you will need to provide the name, which again is the same name as the call back parameter passed to the helper, a method to call when the notification is seen, and the object being passed, which is userInfo, that contains the dictionary you set up in the helper. In your method you will get the dictionary out of the notification’s userInfo and retrieve the response data from it. And now you’re back to where you were before, you have response data in your view controller that is ready for your manipulation and use, use it wisely.

Awww, that can’t be it, surely there’s more

Well there’s not! Ok, there could be, but they’re outside of the scope of this simple tutorial who’s only goal is to get you thinking about implementing cleaner easier to manage code. If you’ve previously dealt with making NSURLConnections and using NSNotifications then you’re probably set, if not, then you should have all the ‘magic words’ needed to find the missing pieces of your knowledge online. But I do have one last thing for you, a reward for reading (and learning?), a reminder that “We are samurai” (oh look, a Hackers quote!!), or at the very least, ninjas:

May the 11th be with you… damn, I should have done this post seven days ago…


less post-apoclyptic & high tension than it sounds

First off, these two clips are not the best representation of either of these bands. The problem exist with my video recording procedure. I could make a clever flow chart to illustrate this process, however, I’m not going to do that (laziness? No! I prefer to write so I can concoct long run-on sentences and ‘out there’ imagery). My process is simple, if a band says something to the effect of “Holy shit, we’re down to our last song, we have stuff in the back, help us, we’re poor”, I calmly react with “Holy shit, hold my beer, I need to record at least the intro to this”. Conversely, if for some reason I am beer-less (which is usually the case for the headlining band since I have no desire to wade through a crowd like a pre-teen trying to make it out of a wave pool at a water park [believe me, that is a journey] just to get another beer) I will (hopefully) be experiencing the show to the point where I only record a video because I am reminded to record a video thanks to the people around me who are recording videos (or taking pictures). Gotta love the age we live in.

The Cave Singers

Good Indie Rock Band. Going with the drums and guitar ensemble, with an occasional harmonica, they actually rock it with feeling, as opposed to more manufactured bands who rock it with baby-sitters on the side of the stage telling them to smile less because it makes them look less threatening… Shinedown sucks.
The Cave Singers don’t though, check them out (I have no idea what the conversation occurring around me is about, but it sounds like that guy is entering the ‘friend zone’, condolences):

Cold War Kids

I first heard these guys on AltNation when the songs from the Robbers & Cowards album were popular (well as popular as indie rock gets anyway). They have a few songs that border on preachy with generic backing ‘music’, but their good shit makes up for those easily. They remind of The Features (whom I am a fan of) with a little more experimental sounds thrown in. Exhibit A:

Music is art, go out and appreciate some.


UIButton

22Dec10

eff IB, let’s code something

Making an iPhone (iDevice) app with a lot of UIButtons? NO??!? Well you should. Let us pretend like you are making an app with many UIButtons, and, that it is a somewhat involved application (you have reasons to avoid IB). The buttons may vary in function and look, but that base code is all the same. And so it begins, the fanatic mantra in your head swelling to a fever pitch, like you’re a member of the Eagles crowd after a ref blows a call (but, you know, without the obscenities), “Don’t Repeat Yourself”.

There are many sites that will show you how to programmatically create a UIButton (which is good, because I don’t do tutorials, I Speak Design [I like that, someone should put that on a t-shirt]), just Google it. Now that you know how to do that, here are our goals:

  • associate an action to the button
  • give it your wonderful graphics

It’s a short list (/cheer). Since you’re putting this button creation code in a helper class you’ll need two things to accomplish this first task, the name of your action, and the struct the method exists in. That is to say, you need a way to tell your helper what to call (method name), and where it’s at (class). To do this you’ll need to pass a NSString that is the the ‘selector name’ and an id that will typically just be ‘self’ from the calling controller/class. You’ll need two things to accomplish the second task as well, luckily, they’re both just images for your button’s normal state and pressed state (which is about as straightforward as killing a zombie… if you know anything about it you can do it). You’re method may look something like this:

+ (UIButton *)buttonWithSelectorNamed:(NSString *)selectorName forStruct:(id)theStruct withNormalStateImage:(UIImage *)normalStateImage withPressedStateImage:(UIImage *)pressedStateImage;

You may also want to include parameters such as the frame (CGRect) for the button, the text for the button (NSString) if you’re images don’t include your text, and so on. And there you have it, you now understand how to build a reusable helper class that can create your buttons. That’s… awesome? (it is)


a problem ChapStick just won’t fix

The Flaming Lips Confetti

Honestly, does ChapStick really work for anyone? Whenever I use it (which is never now) it just seems to pretend to be helpful while slightly affecting my mood. Now you’d think I’d make a comparison to a seemingly vacant woman giving you advice on a Christmas present choice for someone she doesn’t know or the extra resource a boss gives you to help with a project (because surely two people can do it in half the time!!), but no, not because they’re not valid analogies, but because it really reminds me of a parrot who was taught to say “look in the cabinet” just squawking away whilst I look for a glass in a stranger’s kitchen. I’m using something from Bath&BodyWorks at the moment, but would love to find something better (my lips feel like they’re being chemically burnt, holding on just enough to protect my face from impending doom, but with no relief in sight because I’m no longer in science lab, and I know not of magical fountains anywhere else).

The Flaming Lips. The Flaming Lips! I now remember what got me started on that tangent (…it was The Flaming Lips). Most people have heard of, or, at the very least, heard a song from these guys (I think Do You Realize was used in several commercials/shows/etc). But what you may not realize is that this show is a true experience. I’d try to describe some of it, but just look at this:

Lead singer of The Flaming Lips on a bear as huge balloons are failing into the crowd

That’s right, he’s on a bear (well a man-bear-suit-guy) singing a song as huge balloons are falling into the crowd. This concert was like those mythical rave parties you hear about but don’t believe in. Check out the opening:

Yes, he did roll out over the hands of the crowd in a big bubble. I won’t bother describing the rest of the crazy awesome weirdness that existed in that place on that night, but do catch The Flaming Lips if you can, it’s like a new age interactive theatre piece with great music. I’ll close this post with a short clip from the closing part of the show, and the song that most people would recognize, Do You Realize:


New Politics

22Dec10

don’t worry, it’s music!

So it’s been a month since my last post. Why do you think that is? Laziness? … yes. And moreover, I’m about to post something that is dated!!1!! However, I’m guessing most people out there don’t know of this band anyway, so hey, it’s still valid (right?).

These guys put on a show. Imagine if you could be with the card guards from Alice partying in the garden, that’d just be fun to experience, and that loose thread is what I’m going to use to relate to this band live, they are an insane experience, seriously off the chain (a phrase I never use, so be sure when you read it you hear a diction more suited for a phrase like, “this wine is delicious”… ya).

I think they’re touring with 30 seconds to mars now, which is not a band whom I own an album of, but hey, I’m sure it’ll be a good show. The only down side for you if you go see them with 30 seconds to mars is that it will likely not be a small venue, it’ll be packed, like sardines in a can (I just enjoy using cliches that are likely to die out soon). When I saw them there were less than 15 people at the show, and they still rocked it, the front man coming off the stage to dance and sing in the crowd, greatness. Based on the lyrics in the clip below I’m guessing they’ve played some small shows before, and don’t give a fuck.

Good people too. Next week on random blogging, more music! Seriously, I have some more videos to put up, so The Flaming Lips clips coming soon (a concert where any weird metaphor I come up with won’t be far off from the reality of it).


NSURLConnection

22Dec10

who wants to code something?

NSURLConnection. This is by no means a tutorial (if it were I’d have to find a way to keep showing that clip of Shredder form TMNT2 saying “a little closer” after ever step, completing the lesson with Vanilla Ice doing ‘Ninja Rap’, but that seems like it would take effort… and “rights”). No, this is a story of NSURLConnection(s) used to retrieve data from RESTful services for an iPhone app (the plot never really thickens).

First off, a quick glance at the way most sites will show you how to use NSURLConnection:

  1. Have your response data object (NSMutableData) initialized and ready.
  2. Create your NSURL that points to your desired target for the data (most typically using the [NSURL URLWithString:@”http://www.didlasseevergetshotlikeoldyeller.com”]).
  3. Make your NSURLRequest and fire off your NSURLConnection, implementing at least the main four delegate methods that accompany the NSURLConnection.

Simple, /cheer. Your UIViewController can now call for data and receive it asynchronously (I just spelt receive wrong [thanks spell check!], but amazingly spelt asynchronously correctly… odd). But what is it we’re actually getting from this request? For me it’s data that represents an object, or a list of objects, in JSON format.

SNR (or “Side Note Rant”, though I’ll never use that acronym again, ever):
I’m of the mind that thinks your object models should be able to initialize themselves with dictionaries, as dictionaries are a staple of Objective-C (plus it’s really ‘effing easy).

SNR over, back to the story! So my calls are getting JSON responses from RESTful services, and converting the JSON response into a dictionary (check out TouchJSON library if you desire to do this), or an array of dictionaries. Afterwards I create my objects from the dictionaries and blah blah blah yadda yadda awesome screen displaying live data.

So here we are, in an app where several NSURLConnection calls are being made, all retrieving different data, but doing it in the same way. This is where I unmask to show my secret identity (if you would, please do some dramatic tension music in your head right now), I’m Rails Fan, and fully believe in the DRYness of it (Don’t Repeat Yourself). On top of that I’m also a good developer, and don’t want to have code that is hard to maintain, which would be exactly what I would have if I make all these NSURLConnection calls from each individual UIViewController.

Onward to the point of this post (congratulations to anyone still reading), and my decision, and looming curiosity about other’s decisions. I created a class (not a protocol), a simple ConnectionHelper class that handles all of my NSURLConnections, leaving it up to the UIViewControllers to call this class, passing in the url and the name of a callback method (which is also implemented in the UIViewController). The general premise is that the helper class holds the code that makes and responds to the RESTful service call, returning a dictionary. Though ‘returning a dictionary’ is misleading, it actually fires off a notification with the userInfo dictionary (the dictionary holding a notification’s payload) set to my translated response, where the notification name is the callback name provided to the helper class. Why is this awesome? Well, besides saving hundreds of lines of code and providing a central place to maintain the NSURLConnection code while keeping the call asynchronous, it sends a notification when done, meaning that any controller subscribed to that notification will be able to act on the data passed (i.e. a parent controller of your current view), saving calls and processing time. This solution is working well for me (very well), but as I cannot seem to find something similar online I’m curious as to if there are drawbacks I’m not noticing.

Any thoughts?




Follow

Get every new post delivered to your Inbox.