Setup Guide

You have multiple options available for integrating DTCoreText into your own apps. Ranked from most to least convenient they are:

Integrating via Cocoapods

If you haven’t done so you add the Cocoanetics Specs repo to your Cocoapods install like this:

pod repo add Cocoanetics https://git.cocoanetics.com/parts/specs.git

This adds the specs for all our components to your search index.

Having set up Cocoapods you add DTNotePadView to your Podfile like this:

platform :ios
pod 'DTNotePadView'

This always gets the latest version of the pod spec from the global repository.

Cocoapods works by copying all source files into an Xcode project that compiles into a static library. It also automatically sets up all header search path and dependencies.

One mild disadvantage of using Cocoapods is that you cannot easily make changes and submit them as pull requests. But generally you should not need to modify DTNotePadView code anyway.

Integrating via Sub-Project

This is the recommended approach as it lets Xcode see all the project symbols and dependencies.

If you use git as SCM of your apps you would add DTNotePadView as a submodule, if not then you would simply clone the project into an Externals sub-folder of your project.

Getting the Files

The process of getting the source files of DTNotePadView differs slightly whether or not you use git for your project’s source code management.

As Git Submodule

You add DTCoreText as a submodule:

git submodule add git@git.cocoanetics.com:parts/dtnotepadview.git Externals/DTNotePadView

As Git Clone

If you don’t use git for your project’s SCM you clone the project into the Externals folder:

git clone --recursive git@git.cocoanetics.com:parts/dtnotepadview.git Externals/DTNotePadView

Now you have a clone of DTNotePadView in Externals/DTNotePadView.

Project Setup

You want to add a reference to DTNotePadView in your Xcode project so that you can access its targets. You also have to set the header search paths, add some framework/library references and check your linker flags.

Adding the Sub-Project

Open the destination project and create an “Externals” group.

Add files… or drag DTNotePadView to the Externals group. Make sure to uncheck the Copy checkbox. You want to create a reference, not a copy.

Setting up Header Search Paths

For Xcode to find the headers of DTNotePadView add Externals/DTNotePadView/Core to the User Header Search Paths. Make sure you select the Recursive check box.

Setting Linker Flags

For the linker to be able to find the symbols of DTNotePadView, specifically category methods, you need to add the -ObjC linker flag:

In Xcode versions before 4.6 you also needed the -all_load flag but that appears to no longer be necessary.

Resources

DTNotePadView has the resources for the yellow paper in the DTNotePadView.bundle resource bundle which gets produced by the “Resource Bundle” target.

Add the “Resource Bundle” target as a dependency to your app so that it gets built Drag&Drop the DTNotePadView.bundle from the Products group into your Copy Bundle Resources build phase so that it gets added your your app.

Setting up Header Search Paths

For Xcode to find the headers of the project add the Externals/DTNotePadView/Core folder to the User Header Search Paths. Make sure you select the Recursive check box.

Setting Linker Flags

For the linker to be able to find the symbols of DTNotePadView, specifically category methods, you need to add the -ObjC linker flag. In Xcode versions before 4.6 you also needed the -all_load flag but that appears to no longer be necessary.

Usage

The DTNotePadViewController is instantiated with a text parameter. If this is nil then the controller will set itself up in Add-Mode, you must present it modally. If you pass text it will assume Edit-Mode, you must present it via pushing it on an existing navigation controller. It will itself take care of the correct way of dismissing itself.

These delegate methods you can implement are documented in DTNotePadViewControllerDelegate

  • notePadViewControllerRequestsDeletionOfNote: is called when the user pushes the note deletion button in the toolbar
  • notePadViewControllerDidCancel: is called when the user cancels editing the note text;
  • notePadViewController:didFinishWithText: is called when the user has finished editing the note text;

It is suggested you implement the first for supporting in-note-deletion and the last to deal with finishing of the editing/adding.

Note that pushing back on the note will automatically save the change, whereas for a new note the customer has an option to cancel.

For use on iPads there is DTNotePadSplitViewController if you need a full screen split view. Though you probably prefer to show the DTNotePadViewController in a UIPopOverController.