The Top 3 Reasons You Need an Apple Watch

Apple Watch White

Apple's attention to detail is second to none.

This is something that I—as someone who has worked for the company—truly believe. This is why I make iPhone apps . . . exclusively. I have become a brand loyalist because, at the end of the day, Apple creates great products and delivers on their promises.

This fact sets the foundation for the top three reasons why you are going to need to own the new Apple Watch. With this innovative new offering, you’ll have the opportunity to connect with people instantly using touch and emotion; you’ll be able to track your health and care for yourself in ways that have never before been possible; and you’ll be on the forefront of technological advancement and medical research as a member of the open source ResearchKit community.

1. Instant Intimacy

This is the word that Apple uses: intimate. When I watched the initial announcement video, I thought this might be a gimmick. So what? It vibrates.

This is not, however, the same feeling that you get when your phone vibrates. That's usually a nagging feeling. It’s not sexy. In fact, when your phone goes off, it usually means you've got something to do.

The Apple watch allows you to connect with others using touch-sensitive technology. It contains a special Taptic engine that creates a three-dimensional feeling so that the person on the other end of the message can feel the pressure, sensitivity and force of the sender . . . it mimics that connection, so that it feels like someone is actually there in the room with you.

After listening to people who have interacted with the device—and actually experiencing it for myself—I realized that the simulation of the human touch is what drives the emotional component of this product. Just imagine: your heartbeat . . . proof that you’re alive.  Someone else is feeling what's happening inside of you at that moment.

With the Apple Watch, you can send a tap, your heartbeat, even a little doodle. It offers the ability to connect with your loved ones in a way that hasn't been possible before.

I've taken several massage classes, and the most important thing I learned from them is that human touch is crucial for our emotional well-being; it allows us to connect with the people around us. It's the Apple Watch’s ability to physically connect one human being to another that is so unique and exciting.

Sure, it’s a simulation . . . but for two people who live 3,000 miles from one another and see each other once a year, it can become a priceless substitute for sorely missed contact.

The animations that you can share with the watch are another part of this human connection. You can convey so much more with a .gif than you can a static image. That's what the animation feature allows: the ability to convey your thoughts to the people that you care about in ways that a simple text can’t. It's super personal, convenient and instantaneous!

2. Health on the Go

The Apple Watch is going to completely change the landscape of personal health and fitness. It’s going to provide the data that people need and provide actionable changes that individuals can make to improve their health.

Some products (the Olio Watch, for example) unapologetically state that they "don't want to focus on fitness." That's fine for some people, but if I’m going to have a computer on my wrist, it’s going to be one that's able to help me with fitness. There's no question about it.

A family member of mine passed away in October of 2014, and I truly believe that this was a situation that could easily have been avoided. That loss really changed my outlook on life and made me focus on how I want to live:

What do I want to put into my body? How much do I want to be working out? How can I make sure that I don't lose precious years of my life to a disease that I could have prevented?

My mom is a dietitian, and part of her work includes teaching people about the causes and results of diabetes. A lot of people go to the classes, but they end up feeling overwhelmed by the amount information they have to absorb and by the idea that they’re going to have to change their daily habits. It's frustrating for them, and I get that.

The fact is that we can control these things . . . but it takes motivation. It takes knowledge, and it takes a mentor—a buddy who can really help you.

The beautiful thing about the Apple Watch is that it allows you to work with the data you have. Armed with that knowledge, you can inspire yourself to work harder, set goals for the future, and even create healthy reminders for yourself. It’s a lot like having a personal trainer on call 24/7.

Steph and I have begun to prioritize our health and fitness because cardiovascular disease and diabetes are things that we want to avoid. We know that we can do that by simply living a healthier life.

Last year, I weighed 184 pounds (and I'm only five-five). I've got a more muscular build, but I was still overweight. I felt fat and it just wasn't a good place for me. Over the past year, I've lost 20 pounds and seven of those pounds came off in a three-month period just this year.

I’ve accomplished this by making small but impactful changes in my day-to-day habits: eating healthier and including larger portions of fresh, organic vegetables; setting myself up for success by planning ahead; and making sure that I’m doing some regular exercise. The exercise part has been really key, and it’s a part of my routine in which I believe the Apple Watch could become instrumental. In the meantime, it’s also inspired me to imagine some great fitness app ideas!

I've always wanted to do one hundred push-ups in a row. I only did it once. It took me four minutes and forty seconds in college, and it was incredibly difficult. I really wanted to get it down to two minutes, but I didn't know if I could. Now that the Apple Watch has arrived, I think it will be possible for me to make an app that would help me—and others—reach that goal.

There are additional features already programed on the Apple Watch (such as the stand-up feature, which you can enable or disable, depending on your preferences) that can help you on your way to making small changes.  For those of us who need that gentle nudge, it’s a great reminder that it's time to move around a little bit, and it can help you boost your energy throughout the day.

The ability to help individuals who need assistance goes hand in hand with offering medical professionals a chance to collect information from a huge population. This brings us to the final reason you will happily stand in line (or pre-order the Watch on April 10th) to get your hands on the latest offering from Apple.

3. Medical research opportunities

The golden ring for the makers and wearers of the Apple Watch is going to be the difference it has the potential to make on a global perspective. I don't see anyone else in this space, and I think this is a great move for the company.

Apple research is going to change the way the medical field approaches data collection and analysis, and Apple is pushing this initiative. Using the sensors on the Apple Watch as diagnostic tools, hospitals, universities, and other individuals will have the chance to create apps that can enhance research studies. This will allow us to interact with all the sensor data on both the iPhone and the Apple watch.

This research is going to give our medical community greater insight into how we function as living creatures. Research studies have to rely on a participant reporting his or her own daily routine, and this information is often inaccurate because people either lie or bend the truth without even realizing it. Researchers will now be able to analyze physical fitness and personal daily habits accurately and determine how both factors affect our overall health.

The best part about it is that you don't have to do anything special. The Apple Watch receives motion data that can be translated into long-term activity levels. It receives and analyzes your vital statistics and compiles the information for long-term analysis. Eventually, it will get to know you and become increasingly more accurate.

At the end of the day, this technology is going to create an opportunity for people who aim to make the world better on a daily basis by providing tools to increase data flow, deepen our insight, and vastly improve our general knowledge. I think that's going to be a game changer.

Moving Forward

Apple is about making the world better. They sell premium products because doing so allows them to create great experiences. I don't see any other company doing it the way Apple does it.

I do think that Apple research is going to be the reason that people switch over to the Apple platform. It's not going to be about customization or syncing with an office cloud or any of that jazz. It's going to be about how we can help make the world a better place; how we can participate in research studies and help people who suffer from illness and disease; how we can help improve lives, find cures, and help people understand the importance of health and fitness. That is why I'm excited about the Apple Watch and I think you should be too.

If you're interested in receiving more information on Apple products, apps and writing code, like this blog posts and subscribe. I'm open to more questions. I want to be talking about Apple and creating experiences using the Apple platform.

You can follow me on Twitter @PaulSolt

How to fix your SKEmitterNode particle effect - Sprite Kit Tip 1

Using special effects in your game is a great way to achieve a unique style or interesting visuals. In this short post, you'll learn how to leverage special effects compositing with the SKEffectNode and the SKEmitterNode.

Subscribe to the iPhone mailing list to learn how to build your iPhone game.

Want to watch the tutorial video? Skip to the bottom.

Out of the box the SKEmitterNode will default to an Additive blend mode (Add) – which can cause special effect glitches. Over dark backgrounds your particles will look like they did in the particle editor, but over white backgrounds they will be washed out and super white (not what you wanted!).

Look at the rocket thrusters for the difference between additive and alpha blend modes

Look at the rocket thrusters for the difference between additive and alpha blend modes

Layer hierarchy and blending control is how you can achieve any kind of special effect in your iPhone game.

I use the SKNode to represent my player, which then has two child nodes: the SKSpriteNode (image) and the SKEffectNode (the particle effect wrapper). Using this structure you can get the same benefits of creating a custom class using the SKNode hierarchy without all the code. 

Inside your didMoveToView() method in your GameScene.swift file, add the following to wrap your SKEmitterNode object in an SKEffectNode object before adding it to your game scene

// The playerNode is the top level object for the main character
//   It composites the image, particle effects, and any other graphics together as a single entity
playerNode = SKNode()
playerNode.position = CGPoint(x: 200, y: 200)
playerNode.zPosition = 5   // The depth should be above any other game objects, but less than any UI
addChild(playerNode)

// Load ship image and display it
playerShip = SKSpriteNode(imageNamed: "PlayerShip1")
playerShip.physicsBody = SKPhysicsBody(texture: playerShip.texture, size: playerShip.size)

// Afterburner - thruster
var playerThrusterPath = NSBundle.mainBundle().pathForResource("Thruster", ofType: "sks")!
var playerThruster = NSKeyedUnarchiver.unarchiveObjectWithFile(playerThrusterPath) as! SKEmitterNode

// Reduce the scale a bit after you play around with the particle effects editor
playerThruster.xScale = 0.5
playerThruster.yScale = 0.5

// Control the composition of the effect (blending) using an SKEffectNode
//  this prevents the white washout with the engine being blended (additive) to the background image
//  you'll see that different colors blend differently as the player moves around.
//  Use this code to fix that issue!
// SKEffectNode's default blend mode is Alpha, so you don't need to change anything to get this to work
//  out of the box.

var playerThrusterEffectNode = SKEffectNode()
playerThrusterEffectNode.addChild(playerThruster)
playerThrusterEffectNode.zPosition = 0  // Below the ship, you could do a flame effect on top for damage

playerThrusterEffectNode.position.y = -20  // move the effect down a bit (based on art/your tastes)

// Make sure you only add the thruster once to the scene hierarchy or you'll see a crash!
playerNode.addChild(playerThrusterEffectNode) 

Try using the code to fix your blending mode glitches – and if that doesn't work let me know.

It can be a little challenging to achieve different visual effects if you don't understand how to composite graphics together in an app or game.

Tutorial Video - How to fix your SKEmitterNode particle effect

 

Want to learn more?

I've been making apps and games for a long time. After working at Apple I decided that I wanted to teach other people how to turn their ideas into apps. If you want to take the first step, but aren't sure where to go – take my iPhone game course.

Swift 1.2 fixes and breaks a few things: you should be excited!

Subscribe for new changes in Swift and iOS app development.

The latest version of Swift 1.2 was released today as part of the Xcode 6.3 Beta. You can start using it today, and you'll get access to some awesome new features.

Apple wrote a blog post on the biggest changes to Swift 1.2 and also posted it's comprehensive release notes on Xcode 6.3 (with Swift 1.2 changes). Download Xcode 6.3 Beta from Apple's Xcode page and make sure you review the changes.

In this post I wanted to comment on a few features that I'm excited about and how you can start using them. Further in the post I'll show you how to convert a small project from Swift 1.1 to 1.2 (manually), and then I'll talk about the great Swift Migrator.

Swift 1.2 breaks a few things in your code. The language changed, so you'll have to change your Xcode projects to adapt.

New Features

1. The Set data structure is available

I'm really excited about the Set data structure, as it was missing (and I missed it from Objective-C).

Set is similar to Array, except that it will make sure you only have a single unique item in the collection. It's great if you want to restrict duplicates for an algorithm or logic in your app. You can also use the powerful set logic, which lets you combine sets through addition or subtraction to create subsets.

Here's a short code snippet to show off creating a set using an Array as input. Alternatively you can add each element individually using the insert() method.

var cardSuits = Set(["Diamonds", "Spades", "Hearts", "Clubs"])

println("Cards: \(cardSuits)")

// Cards: ["Diamonds", "Clubs", "Spades", "Hearts"]


cardSuits.insert("Diamonds")  // no error, but no insert happens

println("Cards: \(cardSuits)")

// Cards: ["Diamonds", "Clubs", "Spades", "Hearts"]


cardSuits.insert("Rocks")  // adds new suit

println("Cards: \(cardSuits)")

// Cards: ["Rocks", "Diamonds", "Clubs", "Spades", "Hearts"]

Set documentation

There is hardly any documentation on how to use the Set collection right now, but you can get the Set methods by Command + left-clicking on the word Set in Xcode (after writing a line creating a set variable). That should take you to the Swift code, which has all the methods available and some sparse comments.

1 - Set Documentation.png

2. "if let" improvements - no more "pyramid of doom"

This one is fantastic. If you've written any kind of user input validation or JSON/XML data parsing you are going to love it.

Before I would either nest a ton of if/else statements, or I would use optionals and then test all the optional values in one if/else statement. The more values you need to test, validate, or compare the more { } curly brackets you're going to be adding. It can then become a little mind-numbing as you try to figure out what block { } you are in, and where another one ends (pro-tip: double click the { to find the corresponding }).

if let name = validateName(nameTextField.text) {

    if !name.isEmpty {

        if let age = validateAge(ageTextField.text) {

            if age > 13 {

                

                // create a new user ...

            }

        }

    }

}

In Swift 1.2  you can combine multiple "if let" values in a single if statement. Plus you get to use where!

if let name = validateName(nameTextField.text),

       age = validateAge(ageTextField.text)

    where age > 13 && !name.isEmpty {

    

    // create a new user ...

}

This change alone is worth the broken code that you'll have to update.

I always felt there was a disconnect between the if/else statements and the switch statements in Swift. Now you can combine multiple statements into a single expression, and you can use the where clause to further limit conditions into a single readable statement.

I much prefer this shorter statement because it keeps the information local, as opposed to putting it in nested if/else statements.

One Caveat - error messaging in the UI

While I do like the concise nature of the statement. Depending on the type of app you might need to provide understandable error messages to the end user.

If you are going to handle any error logic you will probably need to leverage semi-nested if/else statements, or you could do all your error checking in a separate method (i.e. validate methods). That way you can be sure to properly warn a user that they didn't add their name to a required field in your signup form.

My test driven philosophy would urge you to not make a method do multiple things, but my shipping apps philosophy would recommend doing the naive approach (just get it working and ship it to the App Store).

Your goal should be to ship your app to the App Store, not writing the most well designed code.

I'd rather see you shipping apps than obsessing over every single code design decision (and not shipping anything).

Broken code: Swift 1.2 breaks existing projects

The biggest takeaways I found when testing out my latest Swift game project were related to types, casting, and converting between Objective-C types (NSString, NSArray, and NSDictionary) to Swift types (String, Array, Dictionary).

Download my iPhone game Xcode project if you want to follow along. It's written for Swift 1.1 and Xcode 6.1. You can learn more about the game in my Swift iPhone game course.

1. NSString isn't a String anymore

You won't get automatic conversion from NSString to String anymore, but it does work in the opposite direction. Apple says it simplifies things, but I'm not sure what that means. Simplifies for them, or simplifies for the programmer using Swift?

To me it seems more complicated, since it'll be another edge case you need to keep track of where the relationship isn't bi-directional. For example in my default Game project, Apple's code unarchiving the Sprite Kit .sks file breaks. They pass a NSString to a method that takes a String.

if let path = NSBundle.mainBundle().pathForResource(file, ofType: "sks") {

Error: Apple is forcing you to add additional type information when converting between Objective-C and Swift

GameViewController.swift:14:61: 'NSString' is not convertible to 'String'; did you mean to use 'as!' to force downcast?

Warning: The auto fix didn't work because the parameter expects an optional value.

GameViewController.swift:14:58: Treating a forced downcast to 'String' as optional will never produce 'nil'

Looking at the documentation for NSBundle, you can see that pathForResource() has an the optional string type: String? as it's parameter.

func pathForResource(name: String?, ofType ext: String?) -> String?

Fix: Change the as! to an as?

Using the as? operator will make it so that if the conversion fails, it'll return nil. And that is what the pathForResource() method expects.

As the Swift language changes you'll run into situations like these. Apple hasn't quite settled yet, so that some code is going to have to change to accommodate new features in the language.

if let path = NSBundle.mainBundle().pathForResource(file as? String, ofType: "sks") {

2. Down casting (i.e.: type conversions) has changed a bit.

You'll need to use the as! to convert between types, which used to work before.

let scene = archiver.decodeObjectForKey(NSKeyedArchiveRootObjectKey) as GameScene

Error: Apple wants you to be more explicit with optional vs. non-optional type conversions

GameViewController.swift:19:82: 'AnyObject?' is not convertible to 'GameScene'; did you mean to use 'as!' to force downcast?

Fix: Change then ending to use as! instead of as

let scene = archiver.decodeObjectForKey(NSKeyedArchiveRootObjectKey) as! GameScene

3. Method signatures have been Swift'ified

With the addition of the new Set class, your touch events methods in both UIControl subclasses or in Sprite Kit SKScene subclasses will have to be updated. There are other APIs in Cocoa/Cocoa Touch that have also been updated. You'll want to look at the full list to see what changed (8.1 to 8.2) and (8.2 to 8.3).

You'll find a lot of method names have changed with the addition of the Set collection class in Swift. Additionally many methods are also using String instead of NSString!, which is a big win for Swift!

override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {

Error: The type has changed from NSSet to Set<AnyObject>

GameScene.swift: Overriding method with selector 'touchesBegan:withEvent:' has incompatible type '(NSSet, UIEvent) -> ()'

Fix: You'll need to update your method signature (i.e.: the entire first line) to the following:

override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {

I'm not sure why it doesn't have the method signature using UITouch. I'd love it more if it used Set<UITouch> since that's what I'll be converting it to. Even still, it's a step in the right direction for Swift. 

Error: Set doesn't have the method anyObject()

if let touch = touches.anyObject() as UITouch? {

Now that you have a Swift Set that has typed objects you need to update your cast if you use one with the touches parameter. 

Fix: Use one of the new methods of Set like first or last, which return optional NSObject values

There's a couple gotchas with this conversion. anyObject() was a method, but first is a property. Firstly, you'll call them differently (i.e: no parenthesis).

Secondly You can't use as? UITouch and as UITouch? interchangeably anymore with Swift 1.2 (not sure if this is a bug or intended feature).

if let touch = touches.first as? UITouch {

 

Swift Migrator: Convert to Swift 1.2

Apple did provide a menu option to do the conversion for you. It works ok, but it's not going to do everything for you.

From the menu bar in Xcode > Edit > Convert > To Swift 1.2

Gotchas

1. It won't catch issues related to APIs changing types (anything that used NSSet to Set<NSObject> or possible NSString! to String).

2. It didn't seem to change things the way I would. Scroll up to see what I recommend as a fix to the code issues in the conversion as a starting point.

3. The recommend quick fixes are not always right, so you'll have to consult the web or read up on Swift.

Conclusion

It's going to be a little bit of work to convert your project. I think you'd spend at least 30-60 minutes working through your project. Any subsequent projects will get easier as you learn what you need to look out for in your older Swift 1.1 code.

From my own experience I find that I have to fiddle with the code (massage it until it works). After I figured out the different edge cases it was easier to convert.

I'm looking forward to when Xcode 6.3 comes out of beta with Swift 1.2!

Connect