Posts filed under swift

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 .

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

I'm on a roll today: make a new Xcode beta launch faster: http://t.co/hWTGV7IzX7

\u2014 Craig Hockenberry (@chockenberry) September 3, 2014\n","width":550,"authorName":"Craig Hockenberry","authorUrl":"https://twitter.com/chockenberry","providerName":"Twitter","providerUrl":"https://twitter.com","resolveObject":"Tweet","resolvedBy":"twitter","resolved":true}" data-block-type="22" id="block-yui_3_17_2_1_1410189204755_28897">

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 . 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

 

 

 

Posted on September 8, 2014 and filed under iOS 8, swift .

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 . 

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

What is 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

\n","url":"https://www.youtube.com/watch?v=3tl55jPmYnY&list=PLLYKjb-Uo9cy3tVE8_7fyxv1aaeN_zTxi","width":854,"height":480,"providerName":"YouTube","thumbnailUrl":"http://i.ytimg.com/vi/3tl55jPmYnY/hqdefault.jpg","resolvedBy":"youtube"}" data-block-type="32" id="block-yui_3_17_2_1_1410100495545_38672">

Connect

Complete Swift iPhone Course

Signup for a beginner . 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

Posted on September 7, 2014 and filed under iOS 8, swift .