Tip

How to Find the Index of a Checked Row in a Table Using jQuery

I’ve been working on a web app for work recently (not my forte), so I’ve been learning a lot of jQuery recently and thought I’d share a little snippet that took me far too long to write:

Basically, what the snippet does, is scan through the table I have on my page and return an array of every row thats had a checkbox checked in. Super simple, but with my limited knowledge incredibly frustrating. Anyway, I hope this helps anyone else that’s had the same issue.

Tip

AFNetworking: Downloading Files with Progress

I was looking for this the other day, and while there are a ton of solutions out there, I felt that all of them were just a tad more complicated than they needed to be to achieve the desired result. Basically, I’m working on an app that needs to download videos and show what percentage of the files have been downloaded in a UITableView. Standard stuff, but for some reason it’s not already built in to AFNetworking. After tinkering around with a few different solutions online, I ended up coming up with my own (shown below). I ended up creating a class called MFVideoDownloader and adding the the following class method to the .m:

While the snippet contains more detailed comments, I’ll just go through what I did really quickly.

    1. First I created the session manager to handle the actual download task that comes about later in the method.
    2. Then I converted the given NSString into an NSURL so it can be used later (I’m working with a REST API that gives me back the URLs I need as strings so it made more sense to convert it here rather than have to convert every place I call the method in app).
Tip

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.

Tip

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.
Tip

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: