Wednesday, June 11, 2014

Apple coding with Swift - new way of coding

Swift 

Swift is innovative programming language for cocoa and cocoa touch. As per Apple website, writing code is interactive an fun, syntax is concise yet expressive, and apps run lightning fast. Swift can be even integrated to current projects since it works side by side with Objective C.

Below are few acclaimed powers of Swift language

Modern : Swift is result of latest research on programming languages, combined with decades of experience building apple platforms. 
Named parameters brought from Objective C are expressed in a clean syntax that makes APIs even easier to read and maintain
Inferred type makes code cleaner and less prone to mistakes while modules eliminate headers and provide namespaces. 
memory is managed automatically and we don't have to even type semi colons. 

var sortedStrings = sort (stringArray)
{
$0.uppercaseString < $1.uppercaseString
}

Interactive Playground
Swift also provides interactive playground where if we write a line of code, the result appear immediately. with the timeline assistance, if the code runs in a loop we can see the progress of it. This approach can be used to test out new APIs, Design a new algorithm, watching results in every step. Create new tests, verifying tests before promote the test suite app. Experiment new APIs to hone new coding skills. 

Read-Eval-Print-Loop (REPL)
The debugging console on the Xcode includes an interactive version of the swift programming language built right in. Use swift syntax to evaluate and interact with the running app or write new code to see how it works in a script like environment. This is available from Xcode console or terminal 

Switft is desgined for Safety
Swift eliminates entire class of unsafe code. Variables are always initialised before use, arrays and integers are checked for overflow, and memory is managed automatically. Simple 3 letter words define the type of the variable. for e.g. var or constant (let) 

as per the overview, swift makes nil handling super easy. It claims that adding single character makes the same effect what would have been achieved by a line of code in objective C.

Fast And Powerful
Swift uses a high performance LLVM compiler which converts the swift code to the native code, tuned to get most out of the modern Mac, iPad, iPhone hardwares. 

Swift takes best features from C and objective C. It takes low level primitives such as types, flow control, and operators. It also provides object - orientated features such as classes, protocols, and generics giving Cocoa and Cocoa touch developers performance and power they wanted. 

Switft is ready today: 
Apple claims that using Xcode 6.0, the Swift code can be included in the existing projects or new projects. When iOS 8.0 and OS X Yosemite are released this fall, developer can submit apps that use Swift to the App Store and MAC store. 


  

Tuesday, June 10, 2014

Whats New in iOS 8.0 - A high level look - Part III

iCloud

Below are three main changes in iCloud that impact behavior of existing apps 

Document-Related Data Migration 
The iCloud infrastructure is more robust and reliable when documents are transferred between user device and the server. When user installs iO8.0 devices does a one time migration of the documents and data in that user's account. The migration involves copying documents and data to the new version of apps container directory. This new container is only accessible from iOS 8.0 or OS x 10.0 Devices running on older OS will continue to have access to the original container, but changes made in that container will not appear in the new container and vice versa. 

Cloud Kit
Cloud Kit framework provides a Conduit for moving data between you app and iCloud. Cloud kit gives full control over when the data transfer should occur. One can use cloud kit to manage all kinds of data. 

Apps that use the Cloud kit framework can store the data in a repository that is shared by all users. This public repository is tied to the app itself and is available even on devices without a registered iCloud account. As the app developer, one can manage the data in this repository directly and see the changes made by the users through the iCloud kit dashboard. 

Document Picker
UIDocumentPickerViewController will let the app to show users the documents that are outside the app's sandbox. This is a simple mechanism for sharing documents between apps It also enables complex use cases because multiple apps can edit the document. 

DocumentPicks documents from multiple providers. For e.g. the iCloud document provider grants access to documents stored in another apps iCloud container. 

Unified Storyboard for Universal apps
iOS provides mechanism for developer to create a single interface for both iPhone and iPad screen sizes. Developer can design app for common interface and then adjust the app for different size classes and can tune for better user experience. 


There are two size classes in iOS 8.0. Regular and Compact. A regular screen size indicates that a large amount of space which is available in iPad or a screen size which gives large amount of scroll space such as in iPhone portrait mode. 

Monday, June 9, 2014

Whats New in iOS 8.0 - A high level look - Part II

Scene Kit

SceneKit is an objective C framework for building simple games and rich app user interfaces with 3D graphics combining high performance rendering engine with high performance high level descriptive API. Scene kit is available in OSX 10.8 and is now available in iOS. OpenGL-EG kind of low level APIs require the developer to implement the Algorithm that display scene in details. With the Scenekit, developer just needs to describe the scene in terms of the objects in it such as light, geometry, etc, and can animate it describing changes to those objects. 

Scene Kit's 3D physics Engine enliven your app or game by simulating gravity, forces, rigid body collisions and joints, 

Sprite Kit
The SpriteKit adds new features that makes easier to support advanced game effects. These features includes integration with Scene Kit, Advanced new physics effects and animations 

AV Foundation framework
AVFoundation framework add support for broad cross-section of audio functionality at a higher level of abstraction than core audio. These new audio capabilities includes access to the audio input and output hardware, audio recording and playback, and audio file parsing and conversion. A developer can also gain access to the audio units for generating special effects and filters, pitch and playback speed management, stereo and 3D audio environments, and MIDI instruments. 

Handoff
Handoff is a new feature in OS X and iOS that extends the user experience of continuity across devices. To participate in Handoff, an app adopts a small API in foundation. Handoff enables a user to begin an activity on one device, then switch to another device and resume the same activity on the other device. 

For Handoff, each on going activity in an app is represented by a user Activity object that contains the data needed to resume an activity on another device. When the user chooses that activity, the object is sent to the resuming device. 

If the continuing activity needs more data than easily transferred by the user activity object, the resuming app has an option to open a stream to the originating app.



References:

Test Flight for Beta Testing

To begin the process, one can open the link betatestingapp.com in the mobile safari and login. After this install the device enrolment profile. This process in the background seems to be sending the UDID to the server for enrol process. This process also install the web clips which can be launched to see if there is any new builds available or not. 

There is a desktop application for MAC which can be used to drag and drop the ipas. Below are few main points about this. 

Test flight detects which UDIDs are in your build's provisioning profile. Teammates who's UDIDs are present on the profile can be selected. You can conveniently select them via distribution lists or individually. 

Greyed out teammates do not have devices on the build's provisioning profile and are not permitted to install this build. 

You can still give access to devices not owned by your teammates by selecting "Include anonymous devices". However, because these users are anonymous, TestFlight is unable to notify them. You can send these anonymous users the build by using the share url which will be available once you submit the build. 

Below given is the screenshot of this ipa upload page. 



Sunday, June 8, 2014

What new in iOS 8.0 - a high level look

iOS Extensions

in iOS 8.0 an app can supply an extension in specific functional areas. Extensions are code that enables custom functionality within the context of a user task. An example would be, if it is a album app, then we can use this extension to have the photo editing feature. User can install and enable the extension. The extension is almost similar to content handler in Java ME, Brew, Or Activity in case of Android. From user experience perspective, when user press on say edit button, the extensions that can do the desired  functionality gets shown in the list and user can choose the extension and do the desired functionality. 

in Xcode, it seems like we can create an app extension by adding a preconfigured app extension target to an app. After a user installs the app, the extension get listed in the settings app and user can enable it. When user is running other apps, the system makes the enabled extension available in the appropriate system UI such as the share menu. 

The common areas where the extension is enabled in the iOS app are below ones: 

Share: share content with Social website or other entities 
Action: perform a simple task with the selected content 
Today: Provide a quick update or a brief task in the Today view of the Notification centre 
Photo Editing: Perform edits to the photo or video within the photo app. 
Storage provider : Provide a document storage location that can be accessed by other apps. 
Custom Keyboard: Provide a Custom keyboard that the user can choose in place of the system keyboard for all apps on the device. 

For each app extension, there is a template which provides APIs for its purpose. With each of these templates, developer get target that contains methods stubs and property list settings defined by the extension point one choose. 

Touch ID authentication
Apps can now use the Touch ID based authentication to give users access to the protected data of the app. For this feature, Applications can make use of Local Authentication framework (LocalAuthentication.framework) to display an alert to the user with an application specific reason for why the user is authenticating. When app gets the reply it can react based on whether the user was able to successfully authenticate. 

Photos Framework:
The photos framework (Photos.framework) provides new APIs for working with photos and video assets including iCloud managed photos. The framework is more capable alternative to the Assets library framework. The main features include thread safe architecture for fetching and caching thumbnails and full sized assets, requesting changes to assets, observing changes made by other apps, and resumable editing of asset content. 

There is also an PhotosUI.framework which apps can use make extensions for editing image and video assets in the photo app.  

Manual Camera Controls
With the AVFoundation.framework, apps can take direct control of the camera control such as adjusting the zoom, white balance, exposure settings. 

Games:
iOS provides high level APIs to make the Game development easy and a the same time provides access to the low level enhancements to harness the power of GPU. overall, iOS 8.0 provides easy ways to implements Games audio and graphics features. 

Metal: 
Metal provides high performance for Graphics and computational tasks by providing extremely low overhead access to the A7 GPU. Metal avoids costly state validation that happens in most of the Graphics APIs. Metal moves all the critical state transition and compilation operations out of the critical path to provide the better performance. Metal provides precompiled shaders, state objects, and explicit command scheduling to ensure the application achieves highest possible performance. Meta is explicitly designed to take advantage of modern architecture considerations such as shared memory, multi processing etc. 

HealthKit framework: 
HealthKit framework allows apps to manage users health related information. This framework provided centralised secure storage for all users health related information. This location can be accessed by many apps and Health app can display this information to the user. 

With an implementing the healthKit framework, apps get access to all health - related information without needing to implement support for specific fitness-tracking devices. The user can ultimately decide which data app get access  to.Once the data is shared with the app, one app can also register for notifications when that data changes. The app can request specific information when it changes. For e.g. the app can decide to get the notification whenever the data changes  or say when the blood pressure is too high. 

HomeKit framework
HomeKit framework provides a standard way to communicate with the connected devices at home. Using this framework, users can discover devices in the home and configure them. User can create actions for these devices and can trigger these actions using Siri. There is a HomeKit accessory simulator that can be used to test the communication of the Homekit with the device. 




Tuesday, June 3, 2014

Android Fragments

Android fragments were introduced for making the life easier for doing the multi panel interfaces and dynamic UIs. Fragments almost act like nested activities. 
A fragment can be created using Fragment class. 

Fragments have its own life cycle events, receives its own input events. or can be removed while the activity is still running. If the app supports API level less than 11, then app may can use the support library provided for fragments. If the app is built for supporting API level 11 or high, then it can just use the Fragment class and related APIs. 

To create the fragment, just needs to extend the Fragment class and override its life cycle events to do the app activities. 

import com.android.os.Bundle;
import com.android.support.v4.app.Fragment;
import android.view.LayoutInflator;
import android.view.ViewGroup;

public class ArticleFragment extends Fragment
{
@Override
public View onCreateView(LayoutInflator inflator, ViewGroup container, Bundle savedInstanceStage)
{
return Inflator.inflate(R.layout.article_view,container,false);
}
}

Fragments also can override other life cycle methods such as onPause() 

On API levels 11 or higher, we can add Fragments to the Activity itself, but on prior versions, we would need to have FragmentActivity.

Fragments are declared in layout XML file much similar to the Views. An example is like below 

android:id="@+id/headlines_fragment"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
/>

the one noticeable limitation is that if the fragment is defined as part of the layout xml file, the fragment cannot be removed at runtime. If there is a plan to remove the fragment at runtime, then we need to add as part of the activity load.