About Joe Hoffman

I am An Electrical Engineer that spends a lot of my off time doing web development and other programming. Currently I am trying to expand my knowledge with iOS and I find that writing tutorials helps me learn more thoroughly as well as provide some useful info to others.

Find more about me on:

Here are my most recent posts

Quick Measurement Conversion

This is a quick writeup on a delightful little gem I found While creating a calculation app. Inside Foundation framework with iOS 10 there is now a structure called Measurement, which takes a value and a unit. The units come from a whole host of categories such as volume, length, mass, and many more. As I come from an engineering background, this fills me with joy. I’m not even sure how often, I will use it, but it just makes me happy. So here’s how you can use it!

Enough Already, Just get to it!

Say you want to convert feet to inches. Well that can be done as simple as this:

let feet = Measurement(value: 5, unit: UnitLength.feet)
let inches = feet.converted(to: .inches)

Well that was easy, perhaps you want to know what 1g on earth is?

let acceleration = Measurement(value: 1, unit: UnitAcceleration.gravity)
let metersPerSecondSquared = acceleration.converted(to: .metersPerSecondSquared)

I can keep going all day with this, but hope this last example demonstrates all the units that are available. There are literally tons. Just type ‘Unit’ and let autocomplete guide you.

Cheers!

Some Things I Learned With Swift

 

Lately I’ve been hard at work learning the in and outs of Swift 3. Now that I’ve finished 3 apps in the language I feel comfortable enough to share a few things I’ve learned in Swift.

Organization

I can’t say whether or not what I’ve been doing in terms of organization is best practice but it looks neat to me, and for the time being, that’s good enough.

Extensions are Sweet

In swift, Extensions are so easy to implement I find myself using them every where. Mostly I’ll use them inside a class to separate portions of code. In Objective-C I would have used the #pragma mark, but in Swift I tend to use the // MARK: – combined with and extension for new sections of code. I’ll typically make a section for properties, styling, and actions to name a few.
[Read more…]

Objective-C and Swift Comparison

This week I thought I would share some notes I took on the differences between Objective-C and Swift at basic level. IE chapter one of Apple’s Swift Programming Language iBook. I encourage you to go download it for free if you haven’t already.

The set of note offered here were just some notes I took while reading the first chapter, I haven’t gone back and edited so proceed with caution.

Anyway, without further ado:

Objective-C and Swift Comparison

Swift Optionals

As an Objective-C developer, the biggest point of confusion for me was with optionals. There are of course other tricky idiosyncrasies, but the hardest thing to wrap my head around was the use of optionals and what the hell “?”,”!”, and “??” means.

Why We Needed Optionals

If you are at all familiar with objective-C , then your well aware that every object had the option of returning nil. To make code safe, we had to typically check for nil all of the time. Often we would set a return nil when something went wrong as well. So we would end up with a bunch of ugly code that looked something like this:

[Read more…]

State of The Union

The presidential state of the union is a designated time where the president can openly complain about his views on the world and update us all on what is going on in his world. Since that is basically what I’ll be doing in this article, that is the title I gave it.

A Brief History

I had spend quite a bit of my free time for roughly a year or two learning Objective-C. Granted, had my day job been working on Apps, I could have learned it a bit quicker. Now that I am a gainfully employed iOS developer I have a few more years of experience under my belt. So imagine my frustration when a new programming language emerges just as I was starting to touch on Objective-C Mastery.

I started NSCookbook with a basic goal. NSCookbook was a method of teaching myself iOS Development while also providing value to the community. I have always found that the best way to learn something is to teach someone else how to do it. As a noob myself, I felt I had a unique perspective that would help out the new comers. What I liked about learning iOS development is everything was new to me and it was fun. Now that I’m more experienced, most of what I will write now is something I already have a pretty good grasp on. In other words, It’s getting a bit boring to me. This is where Swift will help me out.

The State of Swift

Swift 1.1 came out with XCode 6.0 and iOS 8. At the time I had guessed that Swift would not be quickly adopted as it was relatively new and buggy. None-the-less, folks adopted Swift in surprising numbers. As of Today, Swift 2.0 is the current version, and is quickly becoming the standard iOS language. This has become an increasingly cumbersome fact for an Objective-C developer for the following reasons:

  1. Every time I’m trying to solve problem that is new in iOS 8 or iOS 9, Most of the solutions that come up in stack overflow are now swift.
  2. New libraries on Apple’s documentations are documented in Swift
  3. Playgrounds are really sweet for experimenting, and they don’t support Objective-C
  4. Once you see Swift, you may realize how much more ugly Objective-C is.

So What Now?

I have noticed That I have been increasingly lazy with respect to my articles. This is mostly because I don’t like the idea of showing both Swift and Objective-C. It’s a lot of damn work, and half of it is largely uninteresting to me. Therefore, Moving forward I’m going to Ditch Objective-C. My primary objective right now is to learn swift. As such, I’d rather not waste too much time with Objective-C. I will however attempt to update old articles that are still applicable with Swift. I hope ya’ll are okay with that. 🙂

iOS Programming Recipe 36: A Fixed Width Dynamic Height ScrollView in AutoLayout

As an iOS Developer it seems I come across a common situation where I want to add a content view with the same width as the screen inside a scroll view. Since most apps need to have responsive layouts, this usually makes sense to do using Autolayout. At first when learning about scrollviews, they seemed like magic. Due to their slightly different rules they were also a bit frustrating.

[Read more…]

5 More Tips and Tricks

The last few posts have been pretty long and drawn out, so this time we’ll make a short and sweet post that helps save you some time. Building on the past tips’n’tricks article, here’s a few more.

Assumptions

[Read more…]

iOS Programming Recipe 35 – Implementing The Common Views: UIPickerView, UITableView, and UICollectionView

Over the past couple years I’ve noticed some patterns when it comes to noobs and the more useful iOS UI elements. Whether your dealing with UICollectionViews, UITableViews, or UIPickerViews, the pattern is essentially the same. And a lot of beginners, don’t quite grasp how similar these views really are. This recipe will focus a little less on the nitty gritty of doing a single one of these view types, and more on how the pattern works for them all. As a bonus, this will be the first tutorial I’ll be doing with Swift. As far as the UI elements go, it’s all the same philosophy, just a slightly different syntax.

[Read more…]

iOS Programming Recipe 34 – Making Your Own Cocoapod

In ruby on rails, which is an open source web framework, there exists a nice system of libraries called “Gems” that can be easily imported into a web project and just used. These gems also have a versioning system, that allows the developer to pick a specific version for the project, or more importantly keep the version consistant so the project doesn’t break because of a future change. Cocoapods gives the iOS developer this same kind of power. With cocoapods you can not only take advantage of thousands of open source libraries, but you can also make your own pods to keep track of several versions of libraries you make yourself. Currently, Apple doesn’t have a good versioning system solution. The community responded with Cocoapods, and today we’re gonna explain what a cocoapod is an how to make your own.

[Read more…]

Memory Management Part II

In part one of this series we talked about the heap, the stack, object ownership, and how reference counting works. In this article we’re going to expand on this to include the role of properties and how all of this works in ARC (Automatic Reference Counting).

[Read more…]

css.php
Privacy Policy