Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kjmcneish

Pages: 1 2 [3] 4 5 ... 46
31
When you use the @testable import attribute, in your testing project, you may receive a "Module was not compiled for testing" compiler error.

To fix this problem:

1. Select the first node in your project do display the Project Editor
2. Select your main project's target
3. Go to the Build Settings tab and set Enable Testability to Yes.

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8

32
FAQs / How to find a specific object in an array in Swift
« on: October 14, 2015, 10:52:44 AM »
To find a specific object in an array in Swift, you pass a predicate that uses Swift's identity operator. For example:

Code: [Select]
let memberEntity1 = member.createEntity()
let memberEntity2 = member.createEntity()
let members: Array<MemberEntity> = [memberEntity1, memberEntity2];
let index = members.indexOf({$0 === memberEntity2})

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8

33
When you port a project to Xcode 7, you often get a compiler warning that states:

"Directory not found for option -F..."

To fix this problem:

1. Go to the Project Editor, select your unit test project's target, and go to the Build Settings tab.
2. In the Framework Search Paths setting, delete the two paths.

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8

34
When you port a project to Xcode 7 and run it in the Simulator, the app does not fill the Simulator screen (you see a black area above and below the scene).

To fix this problem:

1. Add a LaunchScreen.storyboard file to the project (you can create a new Xcode 7 project and copy the storyboard file into your project).
2. In the Project Editor, select the project's target and set Launch Screen File to LaunchScreen.

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8

35
News Items / Revamping the Book Series
« on: October 01, 2015, 01:27:57 PM »
FYI, we have revamped the book series, making "Learn to Code in Swift" Book 2 of the series, and removing "Flying with Objective-C" out of the series, making it a standalone book. This reflects our change in promoting Swift over Objective-C programming.

All the best!
Kevin McNeish

36
Book Updates / Diving into iOS 9 now available in the iBooks Store!
« on: October 01, 2015, 08:33:12 AM »
The iOS 9 and Xcode 7 version of Book 1 is now available in the iBooks Store!

https://itunes.apple.com/us/book/book-1-diving-in-ios-app-development/id558788074?mt=11

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11

37
Book Updates / Mastering Xcode 6 and Swift
« on: October 01, 2015, 08:30:10 AM »
Mastering Xcode 6 and Swift is now available in the iBooks Store!

https://itunes.apple.com/us/book/book-3-navigating-xcode-4.5/id598559434?mt=11

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11

38
General Discussions / Re: xcode 7.0.1 Assistant Editor
« on: September 29, 2015, 05:34:49 PM »
It will do this if you haven't specified a custom view controller class for that particular scene. If you create a custom Swift view controller class for that scene, it will appear in the Assistant Editor.

All the best!
Kevin

39
General Discussions / Re: mmBusinessObject update
« on: September 25, 2015, 11:13:26 PM »
Yes, I have attached it to this message!

All the best!
Kevin


40
FAQs / How to add a background image to a table view
« on: September 21, 2015, 10:53:58 AM »
To add a background image to a table view, you create an image view and add it to the table view's backGroundView property.

For example:

Code: [Select]
let imageView = UIImageView(image: UIImage(named: "StarrySky"))
imageView.frame = self.tableView.frame
self.tableView.backgroundView = imageView

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8

41
FAQs / How to stop a UIImageView animation on the last image
« on: September 15, 2015, 04:04:27 AM »
By default, at the end of an animation, UIImageView clears its display. If you want it to display the last image in your animation once the animation is complete, all you have to do is set the UIImageView's image property to the last image in your animation sequence BEFORE setting the animationImages property.

For example:

Code: [Select]
self.imgRobot.image = UIImage(named: "RobotYawnWait156")
self.imgRobot.animationImages = imagesArray

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8

42
I found a great little extension to UIImageView that allows you to specify a block to be executed after the UIImageView animation is complete. Unlike other solutions that use a timer (bad idea). It uses CAKeyframeAnimation instead, with its animationDidStop method, which is far more reliable:

https://github.com/gurmundi7/UIImageView-AnimationCompletionBlock

It's written in Objective-C, so you Swifters just need to add it to your project and then import it in your bridging header file:

Code: [Select]
#import "UIImageView+AnimationCompletion.h"
All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11

43
FAQs / The difference between your app's Base SDK and Deployment Target
« on: September 13, 2015, 05:15:53 AM »
Your app's Base SDK specifies the highest version of iOS that your app supports. When your app runs on a device that is running your app's Base SDK, it runs the full feature set available in your app. The Base SDK should usually be set to "Latest iOS".

Your app's Deployment Target specifies the minimum version of iOS that your app supports. So, your app's Deployment Target should always be set less than or equal to its Base SDK.

If your project has multiple targets, you can set the Base SDK at the project level and the setting is inherited by all targets. You can also change the Base SDK for a particular target at the target level.

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8

44
FAQs / How to add a new framework project to an existing project
« on: September 12, 2015, 11:25:48 PM »
To create a new framework project and add it to an existing project:

1. In Xcode, select Editor > Add Target... from the menu.
2. Under the iOS section on the left, select Framework & Library.
3. On the right, select either Cocoa Touch Framework, or Cocoa Touch Static Library
4. Click Next
5. Fill in the dialog with the options for your new framework target. Make sure Embed in Application is set to the project you want to reference the Framework from.
6. Click Finish.

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8

45
In Swift 2.0, you no longer use the count() free function to count the characters in a string. You call the count() method on the String's character property instead.

For example, the following code uses the count() function to count the characters in a label's text property:

Code: [Select]
let i = count(self.lblWinnerText.text!)
This should be changed to:

Code: [Select]
let i = self.lblWinnerText.text!.characters.count
All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8

Pages: 1 2 [3] 4 5 ... 46