Category Archives: Uncategorized

First look: CKSideBarController, a UITabBarController for iPad

November 26, 2012 | Jason Kozemczak

tl;dr

For the past several months, I’ve been working on number of projects that utllize a view layout similar to Twitter for iPad. For those that haven’t seen Twitter for iPad, the app has a root view that essentially shows a vertical tab bar on the left. When content under a certain tab needs the attention of the user, a “glow” appears on the tab.

You can get the source on Github!

To help kickstart others who want to organize their app in a similar fashion, I’ve created CKSideBarController. Its API operates very similarly to UITabBarController, and its look and feel is clean:

Screenshot1

Todos

CKSideBarController is young. As in, I wrote it yesterday. Currently, there’s no way to customize the look and feel of the Controller’s view. Fortunately, the styling code is fairly easy to find (Search for “UIFont” or “UIColor” to get rolling); so definitely fork and style to match your app!

CKSideBarController adds a category to UIViewController that allows you to configure the UIViewControllers being managed by the CKSideBarController via a `sideBarItem` property. If you change a property on the sideBarItem in your view controller, it will not automatically update the corresponding tab (for example, if you were to change the tab’s image). You need to manually refresh the CKSideBarController via it’s `refresh` method. Ideally, the CKSideBarController would do some KVO magic to determine when it needs to update the displayed tabs.

Getting Started

If you’ve stuck around, it means you’re interested in CKSideBarController, blemishes and all! If you’re adventurous, you can get a good idea of how to use CKSideBarController and what you can do with it by looking at the example project included in its Github repository.

The easiest way to use CKSideBarController would be CocoaPods, if I had had time to get a spec written for it NOTE: if you want to a make a Podspec for the controller, please do and let me know when it’s published!). a Podspec outstanding, you can simply clone the Github repo and copy all the files under the `Source` directory into your XCode project. CKSideBarController is written using ARC, FYI.

Like UITabBarControllers, UISplitViewControllers, etc., CKSideBarController works best as the window’s `rootViewController`. With that in mind, you’ll probably want to save a reference to the side bar controller in your App Delegate:

If you were to run the app with the above code, you’ll see an empty side bar with no content. You’ll need to give the view controller some UIViewControllers to handle!

Now that we’ve given the side bar controller some views to manage, we can configure the individual view controller’s `sideBarItem` to customize the look of the tab representing the view controller. Remember to import the CKSideBarController header file or else you won’t see the `sideBarItem` property on your UIViewControllers!

If we re-run the app, we’d see the side items populate with images, titles, and a pleasant glowing effect. Awesome! If we want even more fine-grained control over tab selection, you can have your app delegate implement the `CKSideBarControllerDelegate` protocol. All of the methods are optional, and allow you to decide if a tab can be selected, as well as being notified when the selection actually happens (not unlike UITabBarController, for example). Be sure to set your app delegate as the side bar controller’s delegate if you want take advantage of these delegate methods.

importing the CKSideBarController header exposes a `sideBarController` property on UIViewControllers, which will return a reference to its ancestor of type CKSideBarController (if it has one), else you’ll get nil. This is in the same vain as UINavigationController and UITabBarController (following in the footsteps of giants).

What’s Next

Please use the controller and let me know what issues you find with it. Be sure to log it in Github Issues and I’ll do my best to look into it. You can also fix it yourself and submit a pull request. I’d suggest running new features by me before submitting a pull request (or do it anyway, whatever), as I try to conscience of feature creep in the controls I write.

Follow me on Twitter to find out more. Send a tweet my way letting me know what you think!

Building Sparrow for Mac, the “open-sourced” email client

September 1, 2012 | Jason Kozemczak

Sparrow was a rather awesome mail client for Mac and iOS that was fairly recently bought out by Google. The acqui-hire caused a big stir in the tech startup scene, and you can find plenty of “fors” and “againsts” throughout the interwebs.

In a rather nice move, Google quickly released “free” versions of Sparrow for iOS and Mac, the caveat being that you have to build it yourself. Today we’re going to walk through the steps to make that happen. You’ll need to be on a Mac, as building requires having access to Apple’s frameworks and build tools.

Installing XCode

Screen_shot_2012-09-01_at_12

Sparrow uses Clang to compile, so we’ll need to have XCode installed. XCode’s available on the Mac App Store, so just use this XCode App Store link to install it.

When you follow the link, the App Store will open to the XCode product page. Click the “Free” button near the top, and click it again when the text changes to “Install.” XCode should begin downloading onto your computer; it will automatically install once the download finishes.

Getting Sparrow for Mac

Next, you need to actually download Sparrow for Mac. As an aside, Sparrow also gave customers the ability to build Sparrow for iOS, but you’ll need to be an registered in the iOS Developer Program to put it on your iOS device. Links to both of the apps can be found in the blog post announcing the availability of the two apps.

After the download finishes, unzip the archive if it isn’t already unzipped.

Fixing the build script

If you navigate to the now unzipped Sparrow directory, you’ll see an ‘app’ directory, and a ‘lib’ directory with a number of static libraries in it. Sparrow essentially gives us an un-linked copy of Sparrow, and we need to use XCode to actually link the libraries.

Fortunately, the guys at Sparrow have included a build script (‘build-mac.sh’) that should make linking a one-line step.

Unfortunately, the path the script uses for XCode will most likely be wrong. Fortunately this is an easy fix. To fix it, open up the ‘build-mac.sh’ file located at the root of the unzipped Sparrow directory in a text editor. On the third line, you’ll see the following:

xcodepath=/Applications/Xcode45-DP2.app

Change the portion after ‘xcodepath=’ to match where XCode is installed on your system. For most people, the line should read:

xcodepath=/Applications/Xcode.app

Screen_shot_2012-09-01_at_12Screen_shot_2012-09-01_at_12

Save and close the editor.

Building Sparrow

After XCode has finished installing and the above edits are in place, we should now be able to build Sparrow. open up terminal and change directories to the Sparrow directory where you just modified the build script; for most people, this can probably be accomplished by the following command:

$ cd ~/Downloads/mac/

And run the the build script:

$ sh build-mac.sh

Running Sparrow

Once the build script returns, all of Sparrow’s dependencies should be linked against, and we should be off to the races! Open ‘app/Sparrow.app’ under the Sparrow directory and Sparrow should launch. It’ll ask you if you’d like it to be moved to the Applications directory; you can do whatever works for you.

Screen_shot_2012-09-01_at_12

After filling in your email details, Sparrow should be up and running.

Screen_shot_2012-09-01_at_12

Enjoyed the post? Let me know by following me on Twitter or DMing me: jaykz52

WTF UIAutomation? Y u no respect object equality?

August 24, 2012 | Jason Kozemczak

I’ve got good news and bad news. Mostly bad news, at least as far as I’m concerned.

An issue was recently submitted on Github for my UIAutomation framework, mechanic.js. Investigating the issue, I mostly discovered that the resolution was mainly clarifying which functions do what. Fortunately, the documentation for mechanic.js is fairly decent (though it could certainly use more concrete code samples), so a simple link pretty much cleared that up.

I also double-checked the implementation of a number of mechanic.js core functions to ensure they were behaving as designed (I even added a few new specs, hurray!). Everything appears A-okay on that front. That’s the good news.

Now, the bad news: While exploring the Github Issue, I came across what appears to be a fairly recent issue introduced into UIAutomation. From what I can tell from my poking and prodding, Apple seems to have broken element equality when comparing UIAElements. For example, if were to loop over an element’s subelements (say, in a UIATableView) and compare an element to itself, UIAutomation tells me they are not equal (a major FAIL in my mind).

To repro this, you can create a simple Single-View App in XCode, drop some elements onto the NIB, assign accessibility labels to those elements (otherwise UIAutomation won’t pick them up), and then run the following script in Instruments, you’ll see the behavior I’m talking about:

What the hell, Apple? This behavior pretty much flies in the face of how the programmers writing automation test scripts think; to that end, equality did work as expected prior to at least XCode 4.3.3. If somebody can confirm that it is also broken in XCode 4.4, I’d appreciate it (my instinct is that it is).

What this ultimately means for mechanic.js is that it’s pretty broken at this point. Most of the functions related to filtering (`filter()`, `is()`, `not()`, etc.) flat out don’t work. Additionally, quite a few of my former team’s existing automation tests are likely broken as result, mechanic.js aside. I’m going to investigate if there’s a workaround I can implement to get mechanic.js back up to working order, but that’s likely not a one-night sort of fix. I utilize referential integrity pretty significantly (like any decent programmer would) in mechanic.js.

I’ve submitted a Radar ticket to Apple for this. Additionally, I’ve opened an OpenRadar ticket that can be duped if anybody reading this post is so inclined to put some weight behind this issue.

I went ahead and created a sample project on Github that you can run to confirm the issue exists. Give it a run and tell me if I’m crazy or not!

Follow me on Twitter to get the latest updates. Tweet or DM me if you’ve got info that might be helpful; thanks!

Listen: iOhYes, a podcast for iOS and Mac Professionals

August 22, 2012 | Jason Kozemczak

My friend and coworker John Sextro approached me last week about being a guest on his new iOS podcast, iOhYes. Of course I said yes!

You can listen to the premier episode and subscribe to the podcast on iTunes.

This week’s episode involves a wide range of topics, including techniques for writing testable code that takes advantage of the power and convenience of UIKit UIViewControllers, AppCode (a new iOS/Mac IDE by JetBrains), what a new iPhone aspect ratio means for  iOS developers, and a round-up of open-source production-ready apps for new iOS developers to cut their teeth on, among other things.

If you like what you hear, follow me on Twitter to here more!

CKCalendar: an iOS calendar with dead simple customization

July 13, 2012 | Jason Kozemczak

I released my first stab at a calendar widget; it’s available on github. The widget is built to work well on iPhone and iPad. On iPhone, the calendar could be presented modally as a date picker for example. A use case on the iPhone might be to host the calendar in a UIPopoverViewController to use as a date picker. The calendar might also be useful as an on-screen widget on an iPad.

Here’s a quick screenshot with the out-of-the-box styling (note that the previous/next month buttons are awaiting styling):

CKCalendar iOS calendar with default styling

Credit goes to my coworker John Anderson for the default theme. Thanks John!

Future plans include further customization of the control, as well as pre-built UIPopoverViewController for iPad apps to easily integrate the tool. Currently, the next/back buttons need some additional work, but I should have that cleaned up by the weekend.

The control is licensed as MIT (with attribution), so feel free to use however you see fit. I welcome link-backs as a sign of appreciation! Enjoy!

Get the CKCalendar iOS control on Github.

There are numerous conditions such as cancer which have no cure. It isn’t tough for immigrants to buy medicines online. How it is possible? You can purchase preparation to treat chronic treatment of the symptoms of osteoarthritis or muscle rigidity. There are various other medicaments. What about levitra cost and how much does levitra cost? What do you already know about http://cialis-vs-viagra.biz/why-order-viagra-online-the-perks-of-internet-shopping-for-meds.html? (Read more cost of levitra). Currently ten percent of men aged 40 to 70 were have trouble keeping an erection during sex. It affects men in all parts of the world. Generally, having trouble getting an erection can be knotty. All kinds of drugs, from those that are elaborate “all natural” to those that are chemically produced in a laboratory, carry some kind of aftereffects. Along with their useful effects, most drugs, notwithstanding, can cause dangerous side effects although usually not everyone experiences them. Online physician services are the only safe variation if you are going to purchase drugs, like Levitra, online.