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.


Topics - kjmcneish

Pages: [1] 2 3 ... 16
1
News Items / Diving into iOS 11 Now Available in iBook Format!
« on: September 20, 2017, 09:33:25 AM »
Diving into iOS 11 in iBooks format is now available in the iBooks Store, to coincide with the release of iOS 11!

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

If you have purchased a previous version of iBook, you can get a free update as described here:

https://support.apple.com/kb/PH19413?locale=en_US&viewlocale=en_US

All the best!
Kevin McNeish

2
Book 1: Diving In / Diving into iOS 11 Now Available in iBook Format!
« on: September 20, 2017, 09:32:18 AM »
Diving into iOS 11 in iBooks format is now available in the iBooks Store, to coincide with the release of iOS 11!

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

If you have purchased a previous version of iBook, you can get a free update as described here:

https://support.apple.com/kb/PH19413?locale=en_US&viewlocale=en_US

All the best!
Kevin McNeish

3
Great news...

Book 2, "Learn to Code in Swift" iBook version is updated to Xcode 8.2 and Swift 3, and is now available in the iBooks Store:

https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11

All the best!
Kevin

4
Swift 3 Code / mmBusinessObject for Swift 3
« on: October 08, 2016, 04:32:25 AM »
If you have been using mmBusinessObject and its associated classes in your own custom projects, here's an update of these files for Swift 3. To use these files, just replace the old version in your project with these updated versions (you only need to replace files with the same name).

All the Best!
Kevin

5
FAQs / How to Add a Border to an Image View
« on: January 26, 2016, 02:53:04 PM »
It takes just two lines of code to add a border to an image view.

In Swift:

Code: [Select]
imageView.layer.borderWidth = 2.0
imageView.layer.borderColor = UIColor.whiteColor().CGColor

In Objective-C:

Code: [Select]
[[imageView layer] setBorderWidth:2.0f];
[[imageView layer] setBorderColor:[UIColor whiteColor].CGColor];

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

6
FAQs / How To Test if Running on iOS, watchOS or tvOS
« on: January 19, 2016, 07:31:29 PM »
You can use the following conditional compilation statements along with the os() function to determine if your app is running on iOS, watchOS, or tvOS.

In Swift:

Code: [Select]
#if os(iOS)
           
#elseif os(watchOS)
           
#elseif os(tvOS)
           
#endif

In Objective-C:

Code: [Select]
#ifdef TARGET_OS_IOS
   
#elif TARGET_OS_WATCHOS
   
#elif TARGET_OS_TV
   
#endif

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

7
When creating a universal app that runs on multiple platforms such as iOS, watchOS, and tvOS you should reuse as much of your app's code as possible, including Core Data.

However, there are some specific steps you need to take to access a single Data Model from multiple projects, to avoid the infamous error "Unable to load class named 'X' for entity 'X'. Class not found, using default NSManagedObject instead."

Here are the main steps:

1. Add the Data Model to the project that contains your Core Data code.

2. If you have separated each of your app's (iOS, watchOS, tvOS) user interface into a separate project (I recommend you do), you need to add a reference to the Data Model in each project's Compile Sources in the Project Editor.

3. In the Data Model, select each entity, go to the Data Model Inspector and make sure the Module setting is blank.

4. In each generated entity class file, add the @objc attribute. For example:

Code: [Select]
import Foundation
import CoreData

@objc(SettingsEntity)
public class SettingsEntity: NSManagedObject {
}

Now you can access the entities from any of your Xcode projects!

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

8
FAQs / How to Use Xcode 7's New "Generated Interface" Feature
« on: November 12, 2015, 10:25:33 AM »
Although Swift doesn't have header files as does Objective-C, Xcode 7 provides a "Generated Interface" feature that allows you to view a virtual header file for a class. This is convenient for viewing all the exposed properties and methods of a class.

To access this option, open a code file in Xcode, then in the Code Editor's jump bar, click the "Related Files" button (the button on the far left that contains four small squares) and then select Generated Interface from the popup menu:



This generates a virtual header file containing all exposed properties and methods:



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

9
If you are using a UIWebView and allow your users to enter any URL in the address bar, you will get the run time error "App Transport Security Has Blocked a cleartext HTTP resource load".

To get around this, you can add the App Transport Security Settings key and the Allow Arbitrary Loads sub key to your app's .plist file:



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

10
tvOS FAQs / How to share custom iOS framework code with a tvOS app
« on: November 07, 2015, 06:54:55 PM »
To share custom iOS framework code with a tvOS app, you need to create a tvOS version of the custom framework, by following these basic steps (assuming you already have a custom iOS framework project):

1. Open your custom iOS framework project in Xcode, and select File > New > Target from the Xcode menu.

2. In the panel on the left in the New Target dialog, select tvOS > Framework & Library

3. On the right side of the dialog, select TV Framework and click Next.

4. In the next step of the dialog, specify the options for your new target. NOTE: Set Embed in Application to your tvOS app, and your tvOS framework will automatically be linked to your tvOS project.

5. Click Finish

Now you're ready to add code files to your custom tvOS framework. Just remember you can add a reference to a source code file in your tvOS framework without duplicating the code file

Note that not all iOS frameworks are available to tvOS apps. Check out this link for a complete list:

https://developer.apple.com/library/prerelease/tvos/documentation/General/Conceptual/AppleTV_PG/index.html#//apple_ref/doc/uid/TP40015241-CH12-SW1

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

11
tvOS FAQs / How to create Apple TV App Icons and Top Shelf Images
« on: November 06, 2015, 04:21:23 PM »


There are three required images you must create for your tvOS app, two of which are shown in the above image:

1. The Top Shelf image (1920 x 720px, single or multi-layered) is shown when the user puts your app in the top row of their Apple TV home screen (the large, image shown at the top of the above image).

2. The Small Icon (400 x 240px, layered image), , which used on the Apple TV home screen (the smaller icon shown at the bottom of the above image).

3. The Large Icon (1280 x 769px, layered image), which is used in the App Store.

Layered Images
Layered images must contain from 2 to 5 layers. The layers are used to give the image a parallax effect when viewed on Apple TV.

You can be created a layered image in several ways. For example:

1. In Photoshop
2. In Xcode
3. Using Apple's Parallax Previewer

I'll skip instructions for Photoshop, but you an read more about it at this link: https://developer.apple.com/tvos/human-interface-guidelines/icons-and-images/. Unfortunately, dragging and dropping images directly into Xcode doesn't seem to work reliably at this time, so I'll focus on using Apple's Parallax Previewer.

Apple's Parallax Previewer
The Parallax Previewer is shown in Figure 1.



You can download Apple's Parallax Previewer at this link: https://developer.apple.com/tvos/download/.

Basically, you add a different PNG or JPG file for each layer you want to add to your icon. You can rearrange and resize these layer images and the Parallax Previewer will create a layered image (.lsr file) for you, which you can import into Xcode.

Here are the basic steps, which you need to perform twice...once for the small App Icon and once for the Large App Icon:

1. Click the plus (+) button at the bottom-left corner of the screen, and select the files you want to add. This adds the images to the left pane of the Parallax Previewer screen.

2. Drag the files in the left pane in the order in which the layers should appear (the image at the top will be the image in the front layer, the second image will be in the second layer, and so on).

3. Select File > Export > LSR... from the Parallax Previewer menu.

4. Select the folder where you want to store the .LSR output file.

5. Drag the .LSR file into your Apple TV project's Assets.xcassets file.

6. In Xcode, drag the individual layers from the .LSR file and into the App Icon (Large or Small) section.

You should now be able to run your tvOS app in the Apple TV Simulator and see your icons and Top Shelf image!

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

12
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

13
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

14
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

15
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

Pages: [1] 2 3 ... 16