Author Archives: Norm

Setting a UIButton’s Image in Swift

yourButton.ImageView?.image is a READ-ONLY property!!!
yourButton.ImageView?.image is a READ-ONLY property!!!
yourButton.ImageView?.image is a READ-ONLY property!!!
yourButton.ImageView?.image is a READ-ONLY property!!!
yourButton.ImageView?.image is a READ-ONLY property!!!

yourButton.setImage(UIImage(named: “name_of_image”), forState: UIControlState.Normal)

OpenMP Clang in Xcode

I’ve been playing around with prime numbers recently, which (naturally?) extended into an investigation into parallel programming. I installed the latest version of GCC 5 (v5.3.0 at the time of writing) using these instructions and got OpenMP running (support is built-in). I’m fine with using Terminal but I thought it would be interesting to try this in Xcode.

I installed the OpenMP C/C++ language extensions for Clang using homebrew with instructions from here. Unfortunately, I received the following error:

can't exec '/usr/local/bin/clang++-omp' (No such file or directory)

It turns out those instructions were missing a symlink that needs to be created. It’s as follows:

sudo ln -s /usr/local/bin/clang-omp++ /usr/local/bin/clang++-omp

Thanks to Stack Overflow for the “full” instructions. I can now build and run C++ parallelized code directly inside Xcode. I am finding a performance difference running the same code via the Terminal vs inside Xcode (which is slower). Hmm…

NBA Playoff Bracket 2016

I just realized I forgot to post this. It’s not pretty, in that it doesn’t look nice. It was done through OfficePoolManager. I couldn’t find an online tool that allowed you to pick your teams like they have for March Madness and the NHL playoffs.NBA Playoff Bracket 2016

UITextView Padding

If you align a UITextView with another element, particularly a UILabel, using Auto Layout you will notice the text in the UITextView is slightly indented. The UITextView is actually implemented inside an NSTextContainer which has some padding around it. To remove this (left/right) padding, set the following property of the UITextView to zero:

textView.textContainer.lineFragmentPadding = 0


Malware on the (Chinese) App Store

Here is a comment I wrote regarding the recent discover of apps containing malware on the Chinese App Store.

1. This is the first such event in over 7 years (and Billions of downloads) of the App Store’s existence, unlike the almost daily occurrence on other platforms.

2. You correctly didn’t echo the false and sensationalized comments of an “attack” on the App Store, as there was no attack.

3. This was limited to Chinese developers circumventing several Apple safeguards. Not that Apple shouldn’t be able to (ultimately) catch this, and they did, but developers should know better than to turn off Gatekeeper, download Xcode from unauthorized servers, and then not check it’s authenticity. Any of these measures would have prevented such an occurrence.

4. Not making excuses but given the security measures within the iOS environment, these apps did virtually no damage. Here’s a quote: Palo Alto Networks Director of Threat Intelligence Ryan Olson claims the impact was likely negligible, with no reports data theft, or “other harm.”

Solving iTunes 3014 Error

For whatever reason, probably because I do iPhone development and am always installing “stuff” on my computer and iOS devices, I’ve run into the dreaded iTunes 3014 error consistently when trying to restore my iPhone/iPad to put a new OS on it. I swear I tried this before and it didn’t work but I just followed the steps below and everything is updating nicely. iOS 9 GM!

  1. Open Terminal and cd to the /etc folder.
  2. Using your editor of choice, mine is nano, open the hosts file (sudo nano hosts).
  3. Enter your password.
  4. Add the following line to the bottom of the file:
  5. Write out/save the hosts file and exit (ctrl-O then ctrl-X for nano).
  6. Finally, flush the DNS cache with this command: dscacheutil -flushcache
  7. All done!