Inverting a UIColor

More safekeeping than anything else (and because I didn’t see it online anywhere):

Super simple method that’s surprisingly useful if you have something like different themes in an app.


Triangular Imageviews

Certainly not the most climactic way to break my year long posting drought, but I’ve been working on an in house app for my devshop that requires a bunch of triangular UIImageviews and I thought I’d share a quick snippet:

The code itself is pretty simple but just a couple of quick notes on the values used:

  • The 44 value in step 1 is the height of the original view, while 60 is the width (and 30 is half that). I tried using more dynamic values (setting 44 to imageview.frame.size.height etc.) but for some reason when using dynamic values in UITableViewCells I’d get some sizing issues and so I opted to hard code the values in. (I’m assuming because it’s still doing some layout calls.)
  • This code actually isn’t limited to just triangles. By modifying the path in step 1 you can make the ImageView any shape at all, it’s just a matter of playing around with the coordinates until you get something you like.

Removing Articles from an NSString

Not much to say about this one. I put this together while trying to ignore the basic articles in front of a song name in my music app. Takes a given NSString and returns a new one sans the article:

You can call it as follows:


How to Push a New UIViewController on Device Orientation Change


At this point I’m sure everyone has seen the iOS Music app’s album view—where you tilt your phone horizontally and the screen suddenly displays all of the album art on your phone.

While viewing a collage of cover art always felt a little useless to me, I always thought the effect was pretty cool and wanted to do something similar in the music app I’m currently working on. As such, I took to google and spent longer than I’d care to admit trying to figure this one out. In the process I got an astonishing variety of errors, but once I finally figured it out the process was actually really simple and not a lot of code at all.

Basically, the code is broken into two methods. The first goes in the vertical ViewController:

and the second in the horizontal:

Here, the first method (the one in the vertical ViewController) is performing a manual segue based on the device’s orientation state. The second method is basically doing the reverse. It dismisses said ViewController, but does so after the UI has had a moment to reset itself to vertical (you get some pretty gnarly errors if you try and segue back before allowing the UI to finish changing orientation). The end result is an effect very similar to the one in the iOS music app. There are a couple of more things to note however:

Project Update

Building a Better Music App : Progress Report 1


After finally getting myself organized two days ago, I’ve finally managed to put something together that actually feels like a somewhat legitimate player. It was a fair amount of hours to get it to the point it is now, but a couple of awesome Cocoapods (thank you BlurryModalSegue and SWRevealViewController!) really sped things up. Furthermore, using MPMediaController is a godsend compared to AVPlayer and I haven’t hit any of the limitations I was worried about running into yet.

As a whole, everything is simpler. Getting organized helped immensely. My code is shorter, easier to read, and more compartmentalized. I’ve been making an effort to comment up my code as I write it as well as taking advantage of pragma marks to be sure I don’t forget where I should insert code snippets I haven’t gotten around to writing yet:

Screen Shot 2014-06-27 at 10.33.00 AM

I’ll be doing a post sometime over the weekend comparing both code bases side by side, but as I haven’t gotten around to doing that yet, I’ve decided to upload a quick video (45 seconds) of my player in action.

Project Update

Building a Better Music App: Getting Organized

IMG_5910 After a long weekend of lots of ugly refactoring moving from AVPlayer to AVAudioPlayer and then back again (more than once because I couldn’t make up my mind) I decided that it would probably benefit me to get just a little more organized in my pursuit of putting together my music app. On that end, spent a few hours the other night putting my ideas on paper and then fleshing them out in a much more thought out approach. On that end, the first thing I start with as clearly defining all of the functionality I’d like my player to have by the time I graduate from Flatiron:

Overall Desired Functionality

  • Play local music
  • Play music on iTunes Match
  • Play songs from Spotify
  • Play playlists from Pandora
  • Play Soundcloud Streams
  • Scrobble to Last.fm
  • Enable favoriting of songs, playlists, and artists
  • Global search across services
  • Specific search narrowed down by service
  • Location based playlists

How to Stop a UISlider from Stuttering in an AVPlayer

After hours of Googling and trying absurdly complex solutions from old documentation to stop the scrubbing bar on my music player from jumping when I dragged it I finally found the solution and it’s annoyingly simple. Just add a call to not update the slider when it’s being touched inside of your update method like so:

Hopefully this tip will save someone else from having to go through the multiple refactoring attempts I did!

Project Update

Building a Better Music App: Part 1


In a recent lab at the Flatiron School, we were asked to make a a basic jukebox app. To be honest, it wasn’t anything super impressive. The app simply played a few built in mp3 files that we imported into our Xcode project. Super basic. But it got me curious as to what I could do almost three weeks in at Flatiron. After quick Google search, I came across this incredible iOS Music app concept by Brye Kobayashi. I love the overall design, and the new functionalities he mentioned look super useful. After emailing Brye to get his permission yesterday, I decided to start on trying to make this prototype a reality.


While I’m still a (far) ways off from my final goal, I’ve already managed to put together two basic prototypes that display and play all of the local music on my iPhone. The first draft (pictured right) I managed to do in a few hours last night. And while it’s definitely not the most visually appealing music app out there (not by a long shot), it was a great introduction to the MediaPlayer and AVFoundation frameworks–both of which I’ve found surprisingly intuitive–as well as extra practice in TableViews. Unfortunately the app always started playing on startup, and scrubbing bar at the top wasn’t working and no matter what example I pulled from I couldn’t get it to work. it seems like because the AVFramework is so massive everyone has a totally different answer.