How to use Popovers on iPad – Part 3: Image Picker

In this series I’ll show you how to create Popovers on iPad. They’re fairly easy to create once you get the hang of the inner workings of the UIPopoverController.

I’ll show you how to create basic Popover in code and in your Storyboard, and we’ll discuss how you can retrieve data from a Popover when it’s dismissed. We’ll do this with a simple UIDatePicker. In the last video I’ll demonstrate how you can pick images from the camera roll using the UImagePickerController with a Popover – which is how you’re meant to do it on iPad.

The series contains three videos in total:

  • Part 1 deals with the initial code and class etup
  • Part 2 deals with setting up the UIStoryboard and connect our code to it
  • and in Part 3 we’ll implement a UIImagePickerController to demonstrate a use case

Enjoy!

Get the code for this project on GitHub

Watch the full course in one convenient playlist:
Catch this episode on my iOS Dev Diary Podcast:

How to use Popovers on iPad – Part 2: Storyboard

In this series I’ll show you how to create Popovers on iPad. They’re fairly easy to create once you get the hang of the inner workings of the UIPopoverController.

I’ll show you how to create basic Popover in code and in your Storyboard, and we’ll discuss how you can retrieve data from a Popover when it’s dismissed. We’ll do this with a simple UIDatePicker. In the last video I’ll demonstrate how you can pick images from the camera roll using the UImagePickerController with a Popover – which is how you’re meant to do it on iPad.

The series contains three videos in total:

  • Part 1 deals with the initial code and class etup
  • Part 2 deals with setting up the UIStoryboard and connect our code to it
  • and in Part 3 we’ll implement a UIImagePickerController to demonstrate a use case

Enjoy!

Get the code for this project on GitHub

How to test the existence of a file with NSFileManager

Here’s how you can check if a file exists in your app’s Documents directory:

This example relies on another method which is usually part of the AppDelegate.m file called applicationDocumentsDirectory. It will return an NSURL to your Documents directory. Just in case you’re working on a project which does not include it, here it is:

How to migrate your persistent store from one location to another

Sometimes you need to change your NSPersistentStore file from one location to another. Or you want to add other options that the old store didn’t have (for example, add iCloud or turn an XML store into an SQLite store). In those cases you can migrate the current store.

Typically this is done by leaving the existing store as is, creating a new store with new properties. Then we’ll tell the NSPersistentStoreCoordinator about our plan, and he’ll swap out the store for us.

Here’s an example: I’ve created a Master/Detail Test App with Core Data and added a few records. All looks good. My persistent store was created by default like this – as provided by the template in AppDelegate.m:

Now I’d like to change the location of the store to a new URL. While I’m at it I could add a new options dictionary – but I won’t show that here, because I’m pretty sure you know how that works 😉

Here’s a method I’m using for the migration:

You can check if the migration has worked by writing out the URL before and after the migration. At this point the old store is no longer in use. If you’d like to go back it it at any time, simply perform another migration.

Demo Project

I’ve added a demo project on GitHub which demonstrates this:

How to use Popovers on iPad – Part 1: Code

In this series I’ll show you how to create Popovers on iPad. They’re fairly easy to create once you get the hang of the inner workings of the UIPopoverController.

I’ll show you how to create basic Popover in code and in your Storyboard, and we’ll discuss how you can retrieve data from a Popover when it’s dismissed. We’ll do this with a simple UIDatePicker. In the last video I’ll demonstrate how you can pick images from the camera roll using the UImagePickerController with a Popover – which is how you’re meant to do it on iPad.

The series contains three videos in total:

  • Part 1 deals with the initial code and class etup
  • Part 2 deals with setting up the UIStoryboard and connect our code to it
  • and in Part 3 we’ll implement a UIImagePickerController to demonstrate a use case

Enjoy!

Get the code for this project on GitHub

Watch the full course in one convenient playlist:
Catch this episode on my iOS Dev Diary Podcast:

How to checkout a previous Tag in Git

Say you have a project and have been tagging particular points of it on the command line using

Sometime later you’d like to go back to such a tag. This is how we can do that.

First, commit your current changes so that you’re free to checkout anything new without losing your hard work. Then simply type

assuming that v1.0 is the name of your tag. Sometimes you may want to checkout this tag and create a new branch while you’re at it, so that your current branch won’t be overwritten. Thankfully we can do this by issuing

This will create a new branch called NewBranch and checkout tag v1.0. Once you’re done working on it you can go back to another branch (for example master) by issuing

Notice that to switch to other branches you only need to give the branch name – unlike with tags which need to be prefixed with ‘tags/’ as shown above.