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 ... 46
16
Carlos,

I made a few changes to your Task class so it works properly.

1. First of all, for the sake of clarity, I renamed the taskEntity property to taskEntityList, so it's more obvious that the property contains a list of entities rather than a single entity.

2.  I changed the code in the getTasksForList() method so it stores the results in the taskEntityList property before returning the results. This matches the pattern in the getAllTaskEntities() method:

Code: [Select]
    // Get all items for this List
    func getTasksforList(listEntity: ListEntity) -> Array<T> {
       
        let predicate = NSPredicate(format: "list = %@", listEntity)
       
        // KJM - Store result in array before returning it
        self.taskEntityList = self.getEntitiesMatchingPredicate(predicate)
        return self.taskEntityList
    }

Q1. When do the ListEntity's "tasks" NSSet gets populated? or does ListEntity remain clueless and it simply trickles up the chain? isn't this like a SQL join?

It's similar in concept to a SQL join. You're asking the Task object to return a list of tasks for a specific list.

Q2. All CRUD functions only take place in the Entity Business Controller, yes? this separation of responsibility is it considered MVVM?

It's a more straightforward MVC (Model View Controller) design pattern.

Q3. Can the mmBiZObj be in the backgroundContext? -- I understand that CRUD must happen in the same Context to avoid confusing CoreData.

Yes, it can

Q4. I know am getting ahead of myself, ReactiveCocoa/RxReactive sounds seductive, could mmBiZObj peacefully coexist? I couldn't find your POV article on ReactiveCocoa.

I haven't worked with ReactiveCocoa, though I've read up on it. That said, mmBizObj can peacefully coexist with ReactiveCocoa.

Q5. Ohh yeah, can I use mmBiZObj or a variation of thereof in a production app?

Absolutely.

All the best!
Kevin

17
I updated the sample code so Chapter 3 is not already completed...sorry for the inconvenience, and thanks for the heads up!

All the best!
Kevin McNeish

18
Sorry to hear about the problems you're experiencing! This happens occasionally with downloads from the iBooks Store. Here's how you can solve it:

1. Make sure you have the latest version of iBooks on your computer
2. Delete the book from iBooks
3. Re-download the book.

This should fix the problem with the video, and with not being able to display two pages at a time...let me know how this works for you.

I'll check out chapter 3's sample code and get back to you!

All the best!
Kevin McNeish

19
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

20
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

21
Carlos,

Can you send compress and send me a copy of your project (you can attach it your reply) so I can better answer your questions?

All the best!
Kevin

22
Book 2: Learn to Code in Swift / Re: TuplesDemo has 2 errors
« on: December 19, 2015, 01:18:04 AM »
Steven,

Sorry for the delay! The forum is supposed to send me a message when a new post is added, but it didn't. Anyway, try it again now...it should work fine.

Thanks,
Kevin

23
Book 2: Learn to Code in Swift / Re: Not in book Can you help
« on: December 04, 2015, 09:25:25 PM »
You can just call the method directly from viewDidLoad:

Code: [Select]
override func viewDidLoad() {
        super.viewDidLoad()
       
       self.TurnOnLabel(self.Label)
}

P.S. Typically, method names should be camel cased (turnOnLabel rather than TurnOnLabel)

All the best!
Kevin

24
Book 2: Learn to Code in Swift / Re: TuplesDemo has 2 errors
« on: December 01, 2015, 11:41:13 AM »
My fault! I fixed the problem with the project and have re-uploaded the sample files:

http://iOSAppsForNonProgrammers.com/SamplesSwift2.html

Sorry for the inconvenience!
Kevin

25
Maxim,

It sounds like your Scheme is set to run the app on a device rather than the Simulator. Just go up to the Scheme control in the top-left corner of Xcode and select one of the iPhone Simulators instead.

All the best!
Kevin

26
Book 2: Learn to Code in Swift / Re: Chapter 7 - "#" doesn't work any more
« on: November 14, 2015, 07:11:32 PM »
Maxim,

Glad you're enjoying the book!

Yes, you're right...I missed this one in the recent update. You no longer use the hash tag, but you simply repeat the parameter name. Here's the updated text:

If you would prefer to give the first parameter in your method both an external and internal name, you can repeat the parameter name, and Swift will create an external parameter name that is the same as the internal parameter name. For example, if you insert an a before the first parameter name:

Code: [Select]
func multiply(a a: Double, times b: Double) -> Double
{
    return a * b;
}

Then you call the method like this:
calculator.multiply(a:5, times: 10)

All the best!
Kevin

27
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

28
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

29
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

30
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

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