Filtering by Author: Paul Solt

Swift - Cannot use += operator with String! from UITextField or UITextArea - Implicitly Unwrapped Optional

I'm guessing this is a bug (submitted bug #, but if it isn't, you'll be surprised to learn that in Xcode Version 6.1.1 you cannot append to a String from a UITextView or UITextField.

The problem is that both the UITextField and the UITextView are using an implicitly unwrapped optional String (String!) as the type. This is messing up the +=, so you either have to break apart the statement (defeating the purpose of +=). Or you have do a force unwrap before the +=.

If you don't you'll get a strange Swift Compiler Error stating that 'String!' is not identical to 'UInt8'

var numberString: String! = "0"
numberString = numberString + "2"

numberString! += "1"
numberString += "1" //'String!' is not identical to 'UInt8'

var textView = UITextView()
textView.text += "More text" //'String!' is not identical to 'UInt8'

var textField = UITextField()
textField.text += "Even more text" //'String!' is not identical to 'UInt8'
Posted on December 11, 2014 and filed under iOS 8, swift .

The first beta of the was launched this past week and developers can now start making apps.

There are some limitations, but Apple released a lot more than was expected for WatchKit. There's a lot you'll be able to do within the restrictions, which are related to the embedded hardware (i.e.: Apple Watch) and it's battery life.

For now, until Native Apple Watch support is added sometime next year (fingers crossed), you'll have to work within the provided mechanisms. If something doesn't work, you'll need to let Apple know by submitting to WatchKit or Xcode.

Known Limitations of WatchKit in Xcode 6.2 Beta

  1. Updated: (Beta 2 allows Watch apps to trigger iPhone apps) You cannot press a button on Apple Watch to cause an action in your iPhone app.
  2. You cannot create or use gestures. All gestures are controlled by Apple.
  3. You cannot move objects around screen by CGPoint position (Maybe with tableview hide/show).
  4. You cannot add UI elements at run-time, everything is design time before app runs.
  5. You cannot make fluid 2D/3D games like Flappy birds (Maybe jittery gameplay with image animations + hiding/showing hackery, + borderless button).
  6. Animations are image-based (in Apple's sample they include 360 images to show a full circle progress bar = 2mb image data).
  7. Your code runs on your iPhone app in an extension (new in iOS 8), and your UI + images reside on the Apple Watch.
  8. Your app will stop if the Apple Watch and iPhone are separated beyond the range of bluetooth. Only Apple can run native apps on device.
  9. You can only use storyboard files for UI (no .xib files).
  10. You must create an iPhone app Xcode project and add Apple Watch targets to create an app.
  11. You cannot use a physical iPhone with the Apple Watch simulator. Only available in simulation on Mac.

With some of the limitations in perspective, you can design apps that provide meaningful information that compliment your iPhone app. The watch is intended to show information that can be used quickly, and it isn't designed as a gaming device because of it's limited battery and processing power.

Download and install Xcode 6.2 Beta from the Apple Developer Website

Go to  and you can download the beta versions of Xcode 6.2 and iOS 8.2 for testing out features relating to Apple Watch.

Scroll down to the bottom and read both the and the .

Download .

Getting Started with WatchKit in Xcode 6.2 Beta

In order to bring you up to speed, I've created a short that demonstrates how to create a WatchKit app using timers. There are some bugs, but this is the best place to start if you want to work with some cutting edge technology.

Please submit any bug reports to and you can help Apple improve WatchKit. Duplicate bug requests are a good thing, because it helps Apple see the more common issues.

Download the

Swift WatchKit Tutorial 1 - Get Started with WatchKit to Make apps for the Apple Watch

WatchKit Swift Tutorial 2 - Getting Started with your First WatchKit App in Xcode 6 2 Beta

WatchKit Swift Tutorial 3 - Apple Watch User Interface Explained

WatchKit Swift Tutorial 3 - Apple Watch User Interface Explained WatchKit Course: http://learn.iphonedev.tv/course/make-apps-for-apple-watch Learn how to customize the User Interface (UI) in your first Apple Watch app. There are limitations and you won't use Auto Layout like in a normal app. It's really different with a grid based layout.","source":"

WatchKit Swift Tutorial 3 - Apple Watch User Interface Explained WatchKit Course: http://learn.iphonedev.tv/course/make-apps-for-apple-watch Learn how to customize the User Interface (UI) in your first Apple Watch app. There are limitations and you won't use Auto Layout like in a normal app. It's really different with a grid based layout.

"},"hSize":null,"floatDir":null,"html":"","url":"https://www.youtube.com/watch?v=UOLi-qqvP_c","width":854,"height":480,"providerName":"YouTube","thumbnailUrl":"http://i.ytimg.com/vi/UOLi-qqvP_c/hqdefault.jpg","resolvedBy":"youtube"}" data-block-type="32" id="block-yui_3_17_2_6_1416584323551_46189">

WatchKit Swift Tutorial 4 - Connect the Apple Watch User Interface to Code

WatchKit Swift Tutorial 5 - Setup a NSTimer in Swift with Apple Watch

WatchKit Swift Tutorial 5 - Setup a NSTimer in Swift with Apple Watch WatchKit Course: http://learn.iphonedev.tv/course/make-apps-for-apple-watch The WatchKit SDK is limited. You can't run code on the Apple Watch with the current beta of WatchKit. This should change when Apple finishes the SDK for native apps.","source":"

WatchKit Swift Tutorial 5 - Setup a NSTimer in Swift with Apple Watch WatchKit Course: http://learn.iphonedev.tv/course/make-apps-for-apple-watch The WatchKit SDK is limited. You can't run code on the Apple Watch with the current beta of WatchKit. This should change when Apple finishes the SDK for native apps.

"},"hSize":null,"floatDir":null,"html":"","url":"https://www.youtube.com/watch?v=WWpd3GGzozY","width":854,"height":480,"providerName":"YouTube","thumbnailUrl":"http://i.ytimg.com/vi/WWpd3GGzozY/hqdefault.jpg","resolvedBy":"youtube"}" data-block-type="32" id="block-yui_3_17_2_6_1416584323551_48217">

WatchKit Swift Tutorial 6 - Synchronize NSTimer and WKInterfaceTimer

WatchKit Swift Tutorial 6 - Synchronize NSTimer and WKInterfaceTimer WatchKit Course: http://learn.iphonedev.tv/course/make-apps-for-apple-watch The WKInterfaceTimer runs only on the Apple Watch and doesn't have a callback to the code running in your app extension. In order to keep everything in sync you need to set a duration variable that is of type NSTimerInterval and set it for both the NSTimer and the WKInterfaceTimer.","source":"

WatchKit Swift Tutorial 6 - Synchronize NSTimer and WKInterfaceTimer WatchKit Course: http://learn.iphonedev.tv/course/make-apps-for-apple-watch The WKInterfaceTimer runs only on the Apple Watch and doesn't have a callback to the code running in your app extension. In order to keep everything in sync you need to set a duration variable that is of type NSTimerInterval and set it for both the NSTimer and the WKInterfaceTimer.

"},"hSize":null,"floatDir":null,"html":"","url":"https://www.youtube.com/watch?v=oGsFX1rEteQ","width":854,"height":480,"providerName":"YouTube","thumbnailUrl":"http://i.ytimg.com/vi/oGsFX1rEteQ/hqdefault.jpg","resolvedBy":"youtube"}" data-block-type="32" id="block-yui_3_17_2_6_1416584323551_49153">

Connect

  • Click the like button below if you enjoyed this post or any of the videos on YouTube.
  • I'll be teaching a on how to make apps for Apple Watch next year.
  • You can start my Swift iPhone app course today with 100+ videos.
Posted on November 21, 2014 and filed under iOS 8, Programming .

Two weeks of a Swift Course and Two Apps on the App Store

Alexandre started the Swift and iOS 8 Apps in 31 Days course and already has two apps on the App Store. Learn about his background and how he's spent his time learning to program new iPhone apps in Swift.

I have found his work to be very inspiring and I hope that you join me in making and selling your first iPhone app.

Not only has he submitted multiple apps to the App Store, but he's also been blogging about the process, struggles, and accomplishments. If you want to learn, this is one of the best ways to get started.

Learn about Alexandre's programming experience and work ethic.

What's your work/education background?

I have a French management business school degree. I'm an entrepreneur; in 2000 I built a recruiting agency in the information technology field.

In 2009, with two partners we created a software company that developed recruitment software in the cloud.

I'm in charge of the sales department.

When did you start programming in Swift? 

I started programming in Swift on September the 20th, after Apple released Xcode 6.0 

Did you have any programming experience before starting Swift?

I have a little experience in Python (our developer team works in Python, so I’ve learned the language to be able to understand them). A long time ago, I played with my HP48 calculator in a language similar to Pascal.

How much time have you spent each week working on programming?

I was really invested in learning Swift and I’ve spent ten to fifteen hours each day for three weeks to catch up on the iOS Developer.

Now I spend four to five hours a day working with Swift.

What do you recommend to other students who are learning Swift?

I would recommend coding their own projects while learning on good materials. I've found it very effective to follow great courses/learning resources and mix that with my own code at the same time.

Watching a video or reading a tutorial is great, but it will bring all its power if you try to make something on your own with that new knowledge. 

Did you have any issues or problems when you were learning Swift?

The main issue was before the beginning, when I tried to picture the amount of things to learn (the language, its concepts, Xcode, Cocoa, etc., etc.). It could be overwhelming.

But "the goal is the way." If you start with a good teacher, it is not about the mountain to climb but about the next step to take.

One step at a time on the right road and everything begins to feel accessible. It is a great journey and a lot of fun. 

How many apps have you submitted to the App Store?

I have two apps on the App Store.

Table Plan

Table Plan

was a development to test if I could build an App. It was a nice learning project because it dealt with math (ellipse), gestures, popover and access to the address book. I'm happy to have published the app, because my mother uses it now. :)

Casual Poet

Casual Poet

is the result of the first App Challenge. It was an insane weekend of development (near forty hours of work in two days). But what a pleasure at the end to have something that looked like a complete App.

It’s more of a proof of concept right now, and it needs more developments to become a real game. I'm working on it now. 

Do you like making apps? What's your goal?

Making apps is really fun and rewarding. It is like a painting: at the end we have created something.

I want to take time to give back to the Swift community too. I've started a blog to share some coding topics I encountered during my developments that could help other developers.

My goal is to continue learning and build great apps. I'm really exited with the Apple Watch. Next year will be a great coding year.

The next step will be to release an App with a high level of quality and a profitable economic model.

Final Words

Awesome Thanks for all the insight into making apps with Swift! Follow or read his Swift programming blog!

Connect

  • Do you have a story to tell? Email
  • Learn how to make apps with Swift.

Posted on November 3, 2014 and filed under Interview .