Troubleshooting

If you have trouble getting your app to work correctly, try the problem-solving approaches described in this chapter.

Diagnosing Provisioning Profile Issues

If you are able to compile your code but the build fails to install on your device, you need to check the provisioning information for your app.

Diagnosing iCloud Availability Issues

When your app calls the URLForUbiquityContainerIdentifier: method to retrieve the iCloud container directory, that method should return a valid URL if everything is configured correctly. If the method returns nil, it could be for one of the following reasons:

The most likely problem to occur during development is that your app’s entitlements are not configured properly. You should double-check the steps laid out in Getting Started to make sure your entitlements are specified correctly and that your app ID and provisioning profile are up to date and being used by your Xcode project.

Code and Compiler Warnings

If things are not working as they should, first compare your code with the complete listings in Code Listings.

Your code should compile without any warnings. If you do receive warnings, it is recommended that you treat them as very likely to be errors. The reason for this is that Objective-C is a very flexible language, so that sometimes the most you get from the compiler is a warning.

When one method calls another method, the method being called must be defined before the method that calls it. If the compiler reports an error that your class does not declare a method with a given selector name, try rearranging the methods in your source file to fix the problem. Except where otherwise noted, you should not need to include the methods in this tutorial in your class declarations.

Check the Storyboard File

As a developer, if things do not work correctly, your natural instinct might be to check your source code for bugs. But when you use Cocoa Touch, another dimension is added. Much of your app’s configuration is “encoded” in the storyboard file. If you haven’t made the correct connections, your app will not behave as you might expect.

Notification Method Names

A common mistake with notifications is to misspell the method name of the notification handler. If when registering the notification observer, you provide a name that is different from the actual method name, the correct method is not called. It is usually better to copy and paste method names when specifying the handlers.