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

I'm guessing this is a bug (submitted bug #19223563, 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'

Xcode 6 Beta is Slow to Open - Fix Gate Keeper Slowness with the Terminal

Xcode 6 Beta

Opening Xcode 6 Beta

After downloading Xcode following the previous Swift 1 - Download Xcode and start your first iPhone app tutorial, you are ready to open up Xcode.

If it’s slow to open a beta version of Xcode 6, the Mac app Gate Keeper is trying to make sure that the 5GB install is safe to use. It might take 1-2 hours to open Xcode beta the first time.

Mac Gate Keeper will scan Xcode 6 for 1-2 hours

Mac Gate Keeper will scan Xcode 6 for 1-2 hours

To speed it up, try this Terminal command. When you make apps or write code, it's good to become comfortable with the command line. You can open Terminal by pressed Command + Space

  1. Open Terminal (Command line on Mac)
  2. Press Command + Space to open Spotlight (Top right magnifying glass)

  3. Type Terminal and press return
  4. Type each line, followed by pressing return (after $ symbol)
cd /Applications
xattr -d com.apple.quarantine Xcode6-Beta7.app
The Terminal app on Mac. It's an amazing command line tool.

The Terminal app on Mac. It's an amazing command line tool.

Xcode 6 Beta will open much faster, and it won't be checking to make sure the file is safe.

Source

Connect

    •    Subscribe and get access to the Swift Primer iPhone app course. Watch 7 videos on programming for beginners.

Complete Swift iPhone Course

Signup for a beginner Swift app programming course. Learn from daily lessons and code exercises with instructor support.

Paul is a great teacher. I started with a couple books and gained some knowledge of programming but Paul really nailed it home for me. Thank you.
— Alex Fernandez

 

 

 

Swift 1 - Download Xcode and start your first iPhone app

Do you have an idea for an iPhone app?

How many days have you been alive? You can make an app for that!

iPhone App Checklist

  1. Download Xcode 6 (2.5GB)
  2. Learn how Xcode works
  3. Make your first app

Download Xcode 6

Xcode is an app, like Word, that you use to make iPhone apps. It's an integrated development environment (IDE), which organizes your code files and image resources for your apps. It also has tools that allow you to track down and fix bugs (bugs mean 1 star reviews).

Download Xcode 6 from the Swift Developer website

After iOS 8 is released, you’ll be able to grab the latest copy from the Mac App Store.

What is Swift?

Swift is the new programming language from Apple, and it replaces the 31 year old language called Objective-C.

If you have never learned a programming language, or how to write code, Swift is the best place to start.

Swift runs your apps faster, it helps protect you from writing buggy code, and it requires less typing than Objective-C. Swift is the new standard for iOS apps. If you want to make apps for Apple’s ecosystem, you need to learn Swift now.

Watch the Xcode download video

Connect

Complete Swift iPhone Course

Signup for a beginner Swift app programming course. Learn from daily lessons and code exercises with instructor support.

The way Paul explains things is perfect for my tell, show, do, review learning style. This is something I never thought I’d get into and I am enjoying thoroughly!
— Dan Texter