Insights from Our Experts

Blog image

Why Cocoa Touch is the beloved of iOS and OSX developers!

Author Image

Akhil Jiji,Software Engineer

Cocoa is the combination of Appkit and foundation while Cocoa Touch is the combined form of UIKit frameworks and foundation. Let us examine the importance of Cocoa in iOS development.
 

Cocoa Touch vs. Cocoa

Considering the collection of frameworks, Cocoa Touch and Cocoa sit on top of them to create API stacks. The other layers are Media,Core services and Core OS. UI classes and API’s have the main difference unlike OS X for the above. For e.g.; instead of NSTextField, you have UITextField.
 

Identifying the Supported Platforms

It is important to keep in mind during development that Cocoa Touch Static Library and Cocoa Touch framework have differences. Practically speaking, frameworks are supported from iOS 8 onwards but libraries can go back to iOS 6. If you need support for version prior to iOS 8, the choice is always for selecting Cocoa Touch Static Library and coding in Objective C.

 

Handoff

Handoff is a new feature that enables iOS and OSX users to extend their user experience to many devices. Handoff enables the user to start an activity in a device and continue it on another. There is a small API in Foundation which track user activity and create an object for each. When a user switches to another device those objects are send to resume the service.

 

Document Picker

Using UIDocumentPickerViewController allows user to access the files in the application outside the sandbox mode. This mechanism helps to share documents between apps. It also takes more complex workflows like editing a single document with multiple devices.

For Example, iCloud document provider can give access to documents placed in another apps iCloud container. 

 

AirDrop

AirDrop lets users to share documents, URLs and other kind of datas across multiple devices. UIActivityController is the master working class behind this functionality.

To receive files through AirDrop, the app must do the following : 

 

  1. Add appropriate keywords to the Info.Plist file.
  2. Add application:openURL:sourceApplication:annotation: method in the app delegate.

 

Files being received are saved in the Documents/Inbox directory. If the user has to modify the files, it has to be moved out from the directory because the files are encrypted in this directory so moving out will help the user to have access to these files if the device is locked.
 

Regarding Swift Support

Cocoa Touch Static Library does not support Swift. So if you have to use it, it is better to consider coding in Objective C. We cannot simultaneously use both static library and frameworks to support all versions. If you need only support from iOS 8 onwards then you can create a Cocoa touch framework in Swift.
 

Cocoa and Cocoa Touch Relevancy

Cocoa and Cocoa Touch can be defined as the set of frameworks which are used to develop OSX and iOS. Since OSX and iOS are Operating systems, it is not mandatory to use Cocoa or Cocoa Touch as the frameworks. So consider Cocoa and Cocoa Touch as synonyms which cannot be merged. There are many development questions around this concerning iOS but anything is adoptable as far as it does not kill the platform!
 

App Extension

User can extend the areas selected on system from iOS 8 onwards by providing an App Extension. It is a custom functionality where user can check beyond the regular context. For example, user can select any content to post to social networks through this extension. When we tap on Share button, the extension accepts, validates and posts the content.
 
There are appropriate API’s for each extension. Property list settings and method stubs have default targets defined by the extension.