Porting my app Biblicious from iOS to OS X, Part 2

With WWDC 2014 coming up, this post probably won’t get read very much, but here it goes…

The first game view hurdle was fixed. In my last post I mentioned that one doesn’t get as many event notifications when a view on OS X is about to display as compared to iOS. My main problem here was that the four NSButtons would not slide off of the screen when the view first became active. They would slide off just fine when one clicked an answer. I determined that the issue was one of timing, between the view being created and me telling the buttons to move when they hadn’t actually been created since the view wasn’t displaying. I was right. This little snippet of code at the end of initWithNibName did the job:

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, .0625 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{

            [self moveOut:kBUTTON_ALL shouldHide:YES];



After the view is created, all I do is wait approximately 600th of a second and then tell the buttons to move out & to start the game.


The second hurdle wasted hours of my time. I increased the font size for all of the controls on the main game view to 36pt. Everything looked good, even the sample text on the four buttons. When I ran the game, the text of the buttons were tiny again, while the rest of the controls were at 36pt font size. I tried everything I could think of, searched StackOverflow, iPhoneDevSDK, and Apple’s own developer forums to no avail. I removed the default dummy text from Interface Builder, I removed the background image of the button, changed the type of button, set the font in code (multiple ways!) using NSAttributedString, tried with setFont, accessed the NSButtonCell property directly and used setFont. I even tried telling the OS to redraw the button by calling the button’s needsDisplay method. I couldn’t change the font size nor the color. I went to the “main menu” of Biblicious and put some code in so if I pressed a button, its text color would change. It worked. I put code in to change the text color of a button if a different button was pressed. It worked, too. I ripped all of that test code out and went to Interface Builder again. I was going to check the font settings in the NSButtonCell instead of just the NSButton. I selected the cell and as I was clicking on the different property inspectors, I saw something weird: BibliciousButtonCell : NSButtonCell. What?!?! When I first started this port back in (apparently) August of 2013, I subclassed the NSButtonCell to properly manage the word-wrapping. All of my hard work was being overwritten by the code in my subclass. In particular, the line that reset the font changes I was making:

NSFont *sysFont = [NSFont systemFontOfSize:16];

To fix the problem, I changed the 16 to 36 in order to match the rest of the game interface. As you can see, the subclass still needs a little work, but at least the text is larger now. I had to get this post out while the frustration was still fresh. Learn from my mistakes. 🙂

First screen with large text

First screen with large text


Porting my app Biblicious from iOS to OS X, Part 1

We have been spoiled by UIKit. I hadn’t realized how spoiled I had become until I started to port my iOS trivia game from iOS over to OS X. One would think that since it’s all Objective-C under the hood, it would be a fairly simple task. It is not. UIKit for iOS gives us Layers automatically which are great for interface manipulation. Need to push a new view on to the screen? The UINavigationController handles that for you: “Here, show me this view. Thanks!” Using Core Animation is easier, and even more convenient thanks to the new Facebook POP Animations. My game used the basic UIKit controls on iOS and therefore, I thought doing the same on OS X would be simple.

On iOS, the user is presented with a TableView of options, one of which is to start the game. Once they choose to start the game, a Game Setup view is pushed onto the navigation stack. Since the app is a Bible trivia game, the player can choose which parts of the Bible to receive questions as well as how long of a game to play.

Since there is no concept of the UINavigationController on OS X, I had to change up the design. To make things easier on me, I have a static sized window that is the same size as the iPad screen when turned horizontally. Instead of a UINavigationController, I have NSViews created in Interface Builder that I swap out in order to update the screen. I also created a “MasterViewController” that uses delegation so child views can tell it when they are done and be popped off the “stack”.

Integrating Facebook’s POP into iOS was quite simple and I’ve taken to using it quite a bit. It really brings the interface to life. When controls slide in, they can extend past their end location slightly and bounce back simulating inertia. Pushing a button can look like it has been pressed. Also, if you want to catch the user’s eye, you can make the icon or text periodically “twitch” for example instead of throwing a modal UIAlertView in the user’s face when asking for a review. In my reading, it looked like POP was able to be used in OS X applications, but I can’t get it to work. When trying to slide an NSButton on or off my view, it crashes with an “unrecognized selector sent to instance”. I’ve made sure the QuartzCore & CoreGraphics frameworks are linked to the project but no joy. Right now I’m using the old school setFrame: method to move the controls around. (Hey, just like iPhoneOS v2!)

The other problem I’m having is that with UIKit, one can display a UIAlertView with no buttons & have it automatically dismiss after a certain amount of time. I have yet to find a solution using NSAlert with AppKit & am afraid I might have to roll my own.

Another plus with UIKit is that there are a bunch of events when a view is instantiated and about to become visible or just became visible… We have initWithNibNameviewDidLoadviewWillAppear, and viewDidAppear. Good things to know! With AppKit, the only events I seem to get are initWithNibNameawakeFromNib. On iOS my game used each of those UIKit events to perform certain actions for either continuing a game after another view was displayed such as the web view, sharing a score, multi-user score board, and the modal blocking “introduction view”. The first OS X release won’t be multi-player so I won’t need to deal with that, but I am currently having game start up issues due to lack of events.


Biblicious Main Screen

So far the main screen looks like this. (Click the thumbnail to get the full size.) I’d like the buttons to fly in from off the screen using POPAnimation, but again, on OS X, it’s just crashing. Once the player has chosen a single-player game or a single-player-practice game, they are taken to the game settings screen.




Biblicious Settings

Again, I’m just swapping out the views to show the settings screen. This is where the using can choose the number of questions and which part of the Bible to use. Clicking on the thumbnail will give you the full size image.




Biblicious Game ScreenAnd then here is the in-progress game screen. Notice the programmer “escape” button in the upper-left corner. You can also see that the text is way too small. I haven’t made a decision about the background image yet. Right now I’m just trying to get the game to function. Again, click on the thumbnail to see the full size image.

Companies that give programming challenges to new hires are doing it wrong.

I’ve been a freelance developer for 10 years. Work has been slowing down a little bit lately so I began applying for full-time telecommute or remote work to test the waters. I’m not sure what the deal is, but 99% of the companies I’ve contacted either want me in the same area as them or want me to come in to the office at least once a week. In this internet age with Google Hangouts & Skype, it seems quite antiquated to require someone to be on-site for a programming gig. I could probably go in for a few hours once a week, but my personal situation requires that I work from home. The “face to face” interviews haven’t been that great either: One interviewer didn’t like that my wife was watching TV in the other room. Another interviewer balked at my salary requirement to sustain my household. He didn’t even attempt to offer me less, he basically stated they had to get their money’s worth from their developers.

Occasionally I get to the point where a potential employer wants a code sample. Picking out a sample of code to impress someone I don’t know, stinks. Over the years as I’ve entertained full-time employment, I apparently never pick out the “right” sample of code. I can only assume something I think is interesting, isn’t to them, or they don’t like my coding style. I have no clue as they never tell me why, even if I ask. That may be part of the problem… programming has always come naturally to me, so what’s cool or interesting? I started programming in the 4th grade (think 1982). I’ve done BASIC, Perl, Visual Basic, REALbasic, Pascal, Java, C, C++, Objective-C, PHP, and more. I enjoy some languages more than others, and some I don’t “do” at all. These days all of my front end stuff is done in Objective-C and back end code in PHP. For one of my iPad apps, I came up with a pretty ingenious chained menuing system for the TableView. I’ve been sending that code… maybe they just don’t understand it.

And here’s my big peeve, the so-called “programming challenge”. I’ve been told that they are not necessarily about programming… it’s about asking for help, seeing how well one works under pressure, understanding one’s thought process… blah blah blah. As someone who is consulting for a living, you potential employer, are not valuing my time. Do you think my client list is fake? How have I been in business for a decade & not able to problem solve? Who do you think made the desktop & mobile apps that I sell? Here is some information you may not realize about me… If you count hobbyist programming, I’ve been coding for 32 years. Hired directly out of college, I’ve been a professional programmer for 15 years. I’ve been running my own business for 13 years, and have been freelance consulting full-time for 10 years. I’ve been a system administrator for every current platform, I’ve been a database administrator, and I can do web programming if I have to; I don’t like it.

When I was hired directly out of college, I started out at a lower rate, with benefits, and was on a three-month probation. If I couldn’t prove myself after three months, I would be let go. After two months I was given a raise and removed from probation. That is the way to do it employers. Allow the coder to learn your coding style guidelines, get to know your existing employees, and prove himself. All of your under-pressure non-real-world coding challenges suck.

Finally, here are some examples:

Please Solve this Programming Challenge:

Given a definition for data within a table structure of:


with cellspan information represented as:


where each member of the array is a value that represents the data that spans multiple columns and the value is the cell span information [rowspan, columnspan]

The above data is equivalent to the table described in HTML as:
<tr><td rowspan=”2″>1</td><td colspan=”3”>2</td></tr>

Write an algorithm that will calculate the final table as a two dimensional array with empty values (null, nil, etc.) for blank spaces.

Write one’s own number formatter without using built-in functions. (20 minutes)

Your goal is to create 115 equal-width columns. The width of each column should be (Window width / 115), and the columns should dock to fill all available width. (60 minutes)

Inside each column, create 12 boxes – one for each “Box0-Box11” value in the .CSV file. The value determines the height of the box – 0.24 means that the box should take up 24% of the column height. If you add up all Box0-Box11 values, you’ll see that they add up to 1.0 (or 100%).

In addition to drawing 12 boxes inside each column, please color them according to their Box number. Box0 should be Red, Box1 should be Orange, et cetera. The actual colors don’t matter – just make sure that Box0 is the same color in every column.


Since there are 115 columns, and 12 boxes in each, you’re drawing a lot of objects on the screen. Your goal is to make this code as high-performance as possible, especially when the window is being resized.

And there are 2 others I can’t think of right now. What a waste.

Cultural Pet Peeve: “No Problem”

I’m not sure if I’ve posted this pet peeve of mine before, but my wife also shares it…

When someone says “Thank You”, the proper response is “You’re Welcome”. The wrong answer is “No Problem”. If someone is thanking you for something; you have served them in some way & they are showing their appreciation. They don’t care if it was a problem for you or not, or if you are being compensated in some other way. They are showing you that you were appreciated, you should show them that you appreciate them as well… maybe you’ll get a bigger tip!

The Cube is now a Lime

While looking over my old blog posts, I found my two “state of Real Software” posts… “REAL Software, the opposite of love is not hate, it is indifference.” and “One year later: Thinking outside the cube.” Those were written in February of 2010 & February of 2011, respectively.

I thought about writing up a nice detailed post about what has transpired since the last post, and decided “Meh (could that be ‘indifference’?), there have been other reviews.” Instead, I’ll simply provide a bullet-point list of what has happened in the world of REAL Software & REAL Studio, and me:

  • REAL Software & REAL Studio are now Xojo, and the cube is now a lime.
  • We finally have Cocoa builds. Yay!
  • The IDE & debugging is now free. One must purchase options to compile stand-alone executables: Desktop apps, Web apps, database connections, and console apps.
  • This year (2013) they put on a conference in Orlando, and they are gearing up for a conference in Las Vegas in (2014).
  • In 2012 I renewed my license for a year because a consulting client asked me to have the latest version. My license runs out next month.
  • Xojo 2013 R3 is much improved over R1 & R2 and I don’t yell at it nearly as much. I’m starting to mesh with the double click to open in a new tab paradigm. Overall I still think the old IDE was a better design. (For example, adding a timer in the UI designer, requires you to double-click the timer and manually add the action event. At that point, you might as well be using Xcode. The RAD in Xojo is gone.)
  • For those wanting to expand their toolset, I started a new blog series From Xojo to Objective C. There I show the reader how to do something in Xojo & accomplish the same thing with Xcode & Objective C.
  • I updated Elastic Window for Xojo & removed the encrypted option.
  • I introduced Elastic Web Page for Xojo.
  • Geoff didn’t like my new blog series From Xojo to Objective C because I opined that if one didn’t need the cross-platform capabilities of Xojo, they should use the platform’s native development environment (be it Xcode or Visual Studio). So Elastic Window for Xojo was unceremoniously booted from their 3rd party store. In fact, I was told that if I retracted that statement, I could once again give them 30% a good chunk of my profits and return to their store. What a deal.
  • I continue to offer consulting services for Xojo. Feel free to contact me.

In non-Xojo news:

  • I’ve updated Biblicious, my 5-star rated Bible trivia game show app, for iOS 7.
  • I’ve updated the bookmark your shopping app, Storemarks, for iOS 7.
  • Like Westminster chimes for your iPhone? I’ve finally released ChimeX for iOS 7.
  • For iPad and iOS 7, I’ve released a SQLite database manager called DBMan SQLite.

Elastic Web Page v1.0 now available

Elastic Web Page for Xojo does for your web apps, what Elastic Window for Xojo does for your desktop applications.

Simply drag the classes into your web project, change the WebPage super to ElasticWebPage and you’re done! That’s all the setup you need.

There are a few issues to be aware of:

  • Fonts are not resized. I found no way to access fonts & their sizes.
  • WebProgressBars can only have their widths resized or they may draw funny which is why Elastic Web Page doesn’t change their height.
  • WebProgressWheels can not have their size changed or they do some crazy sliding/looping animation. Elastic Web Page will just move those controls and not change their size.

Elastic Web Page is $150 for the source code only version. If you already own a license for Elastic Window, you can get 33% off and only pay $100 for a source code license.