Tuesday, August 2, 2016

Drawing chart using Core Plot in iOS

Core Plot
  • Core Plot is one of the great framework to create chart in iOS. It has awesome feature to draw smooth and nice chart. Here is some overview about core plot.

Introduction:

Core plot is a 2D plotting framework for iOS. We can draw many type of graph using core plot library. We can use core plot library for Mac OS X and iOS.
You can draw many type of graph using core plot. They are 
  1. Multi Color Bar chart
  2. Vertical bar chart
  3. Curved scatter plot 
  4. Math function plot 
  5. Candlestick plot
  6. OHLC (Open high low close chart) plot
  7. Range plot
  8. Donut chart
  9. Pie chart
  10. Real time plot
Structure:
  • Layers: There is a CPTLayer class, which is a subclass of CALayer. CPTLayer class used to produce vector images, quality graphics and to support event handling. It is used to draw graphics on the screen.
  • Graphs: This is main and central class of core plot. It is an abstract class and all classes derive from it. It works like a complete diagram which includes axes, labels, title and more than one plot.
  • Plot area: CPTPlotArea class represents the plot area. It includes data plotting, axes, grid lines and too name a few.
  • Plot Spaces: CPTPlotSpace class represents plot spaces. It has to implement methods for transforming from drawing coordinates to data coordinates. Here data coordinates are the points passed by array points and Drawing coordinates are the view point on the graph.
  • Plots: Anything we draw on graph represents plot. There are various types of plotting like Line, Scatter, bar plot or histogram plot. A graph has multiple plots. So every plot has a set of number of plots point and set of data. CPTPlot class is an abstract class of all plotting class like CPTScatterPlot and CPTBarPlot.
  • Axes: A basic graph has two axis x and y. CPTAxis class is used to represents data to the x and y-axis. CPTAxisSet is used to creates two axis x and y.

For more information about core plot example and framework, please visit this link,

https://github.com/core-plot/core-plot/wiki/High-Level-Design-Overview

iOS 9 New Feature

Apple released iOS 9 with the great bunch of feature. Here are the summery of important features.

Multitasking Enhancements for iPad

  • iOS 9 enhances the user’s multitasking experience on iPad with Slide Over, Split View, and Picture in Picture. 
  • Slide over feature to open secondary app

Search

  • App Search in iOS 9 gives users great new ways to access information inside of your app, even when it isn’t installed.
  • When you adopt iOS 9 Search, users can access activities and content deep within your app through Handoff, Siri Reminders, and Search results.
  • In addition to improving the user experience, adopting Search helps you increase the usage of your app and improve its discoverability by displaying your content when users search across the system and on the web.
  • The NSUserActivity class includes new methods and properties that help you index activities and app states to make them available in search results.
  • The new Core Spotlight framework (CoreSpotlight.framework) provides APIs that help you index the content in your app and enable deep links to that content.
  • Adding the appropriate web markup to your website makes your related web content searchable and helps you enrich the user’s search results.
  • The three Search-related APIs are designed to work in concert.
  • Use NSUserActivity APIs to Make App Activities and States Searchable
  • NSUserActivity adds API that lets you designate specific activities or app states as searchable. When a searchable activity or state appears in Search or Safari results, users can tap the result to return to the relevant area in your app. 
  • Use Core Spotlight APIs to Make App Content Searchable
  • Core Spotlight provides a database-like API that lets you add, retrieve, update, and delete items that represent searchable app content. When you use Core Spotlight to index items, you make it easy for users to search their own content.
  • Use Web Markup to Make App Content Searchable
  • If you mirror your app content on a website (or your app gets all its content from a website), you can use web markup to give users access to your app content in Search results. Because Apple indexes web content and makes it available in Search and Safari, it’s crucial that you add markup to help Apple discover and index your content and display rich results.
  • Adopting Smart App Banners is the best way to help users of your website discover your app. Including an app-argument in your Smart App Banner markup allows Apple to index your content.
  • The following schemas are supported:
    • AggregateRating
    • Offers
    • PriceRange
    • InteractionCount
    • Organisation
    • Recipe
    • SearchAction
    • ImageObject
  • Use Universal Links to Enable Your App to Handle Links to Your Website :

Gaming

  • New feature and improvements in Gaming.
    • GameKitPlay
    • Metal
    • Metal shaders
    • Model i/o
    • Metal kit

App Thinning 

  • It includes on demand resource handling.
  • Creating and assigning tags
  • On-Demand Resource Size Limits: It will be 2 GB for one tag. The total size will not be more than 20 GB.

Supporting Right To Left Language

  • it makes easier for you to provide a flipped user interface. 
  • Standard UIKit controls automatically flip in a right-to-left context. 
  • UIView defines semantic content attributes that let you specify how particular views should appear in a right-to-left context. 
  • UIImage adds the imageFlippedForRightToLeftLayoutDirection method, which makes it easy to flip an image programmatically when appropriate. 

App transport security


  • App Transport Security (ATS) enforces best practices in the secure connections between an app and its back end. 
  • ATS prevents accidental disclosure, provides secure default behaviour, and is easy to adopt; it is also on by default in iOS 9 and OS X v10.11 

Extension Points


  • Network extension point
  • Safari extension point
  • Spotlight extension point
  • The audio unit extension point

Contacts and Contacts UI


  • Modern object oriented replacement for the Address book

Watch connectivity


  • It provides two way communication between an iPhone and a paired Apple Watch.
  • It supports immediate messaging between the app while it is running.

Keychain 


  • More item protection and new type of encryption keys
  • New constraints for access control lists that allow creating constraints with touch id only or passcode only.
  • A new touch ID constraints that invalidates keychain item when a finger print is added and removed.
  • Support for authentication context

Swift Enhancement

Addition framework changes : 

It Includes many new improvements in iOS 9

  • AV Foundation Framework : 
    • The AV Foundation includes new AVSpeechSynthesisVoice api that lets you identify voice by identifier instead of language. You can use name and quality property to get information about voice.
  • AVKit Framework : 
    • It provides AVPictureInPictureController and AVPlayerViewController classes, which helps you to use picture in picture.
  • Cloud kit Framework : 
    • You can use CloutKit Js (a java script library) to provide a web interface for users to access data of your app. You should have schema for database to use web interface to fetch , create, update, delete and save records.
  • Foundation Framework :
    • Api for on demand loading of NSBundle resources.
      • Strings file support for context - dependent variable width string.
      • NSProcessInfo apis for power and thermal management.
  • HealthKit Framework :
    • The health kit framework has following enhancement.
    • New support for tracking areas such as reproductive health and UV exposure.
    • New support for bulk deleting and tracking deleted items.
  • Local Authentication framework :
    • It includes following enhancement.
    • Support for reusable Touch ID matches
  • MapKit Framework :
    • It includes several addition that help to provide rich user experience.
    • It supports querying transit ETAs and launching map into transit direction.
    • It supports 3d flyover mode.
    • Fully customized Annotation.
    • Search result for map kit and CLGeocoder can provide a time zone result.
  • PassKit framework :
    • Several addition to enhance Apple Pay. Specifically,
    • In iOS 9, Apple pay support discover cards and store debit and credit cards.
    • Card issues and payment network can add cards to Apple Pay directly in their apps.
  • Safari  Services Framework
    • It includes SFSafariViewContoller, which has following feature
    • It used to display web content within your app.
    • It shares cookies and other website data with safari and many safari great feature like Auto fill and Safari reader.
    • It is used to display a single page and it has done button which can user where they were in app.
    • If your app display web content and does not customise its content then replace WKWebView and UIWebView with SFSafariViewController to customise web content.
  • UIKit Framework
    • It includes following enhancement,
    • The UIStackView class is used to manage a set of subviews as a stack that can be arranged vertically and horizontally.
    • New layout anchors in UIView (leadingAnchor, widthAnchor), NSLayoutAnchor and NSlayoutDomain which helps to make layout easy.
    • New UILayoutGuide: It help you to adopt readable content margins and define where within a view the content should draw.
    • New UIApplicationDelegate method to open a document in place, instead working with a copy of document. To support in Open-In-App functionality , an app should add to its info.plis file the LSSupportsOpeningDocumentsInPlace key with a value Yes.
    • UItextInputAssistanceItem class helps you to layout bar button groups in shortcut bar.
    • Enhancement to touch events
    • Enhancement to UIKit Dynamics, New UIFieldBehaviour with additional attachment types in UIAttachementBehaviour.
    • New behaviour property in UIUserNotificationAction , which lets you support text input from users in notification.
    • New NSDataAsset, which makes easy to fetch content tailored to the memory and graphics capabilities of your device.
    • All standard UIKit flip appropriately to support right to left languages. Like Navigation gesture , collection view and table view.

Monday, August 1, 2016

Multitasking enhancement for iPad in iOS 9

In the release of iOS 9, apple introduces several new features. Multitasking is one of them for iPad. 
With the new multitasking, 
  • There are new features for iPad users i.e.
    • Slide over
    • Split view 
    • Picture in Picture. 
  • The slide over feature let the user to use a secondary application at side bar and quickly to interact with. 
  • The Split view feature let the user to use two applications side by side simultaneously on iPad Air 2.
  • The picture in picture feature let the user to play video at small screen and can be float on the window.
It is very essential to keep in mind that when user uses multitasking, app should use system resources very efficiently. 
The application should be responsive. 
Developer has to use size classes for the application so in multitasking, application’s user interface looks proper.
There would be memory pressure on system when user using multitasking. 
The app that has more memory pressure will quite first. So developer has to create energy efficient iOS app, below are some guidelines to create energy efficient app.

You application should require:
  • Great battery life
  • Awesome speed
  • Responsiveness
  • Cool device
To achieve this you should use below technologies,

Energy Essential:
  • CPU uses more energy for every task. You should use CPU when you need it by scheduling, batching and prioritizing.
  • iOS device saves lot of energy by sleep. When it wake up it uses more energy to boost device performance. It will cost on battery. So app should not perform any task when it is in background and you should not wake up device with every push notification.
  • Your app should avoid updating user interface when it is not visible.
  • Do not make location request when not needed. More accuracy in location will take more time and consume more battery, so avoid accuracy whenever possible.
  • Similarly avoid using accelerometer, gyroscope, Bluetooth and magnetometer whenever not require.
Reduce and Prioritize work:
  • Your app should work less in background state.
  • Suspend your task when app goes to background.
  • Stop your animation, operation and User interface updates when application goes to background. If your app uses background execution like downloading content then app should notify the end of process to the system.
  • Your app should use QoS (Quality of service class) to prioritize work. QoS is used to give priority to task. It is available from iOS 8.
  • You can decrease battery consumption by using energy efficient APIs instead of timer.
  • Timer are set to fire after some interval, in that period CPU has to wait and battery consumption increases. In that case use GCD tools and get event notification without using timers.
  • When there is low battery in iOS device, your app should reduce CPU and GPU usage, stop animation and other heavy task.
Minimize and defer network:
  • Your app should not download same content.
  • Use caching to download data.
  • Check network signal condition, use SCNetworkReachability Api to check network host. If there are network problem, alert user to request data when signal available.
  • Always use batch transaction for fetching data. If you are downloading video then download complete video at once rather than small downloading small portion.
  • If there is an advertize in the app then download all ads at once then show over a period.
User Graphics, Animation and video Efficiently:
  • When your app uses standard control and window, there is no need to update content.
  • When your app draws or performs animation, it uses CPU and GPU. So do not use animation whenever not require.
  • If you are using opacity, do not use it over content that changes frequently.
  • Do not perform drawing on view when there view is not visible.
  • Do not use different frame rate animation simultaneously. Suppose you performing animation on view A at rate of 60 frames and using frame rate 30 for View B. It causes more battery drain. Then use 60-frame rate for both view.
  • It’s not recommended to add any content while playing full screen video.
Reduce location accuracy and Duration:
  • Using location service, application will get updated location. But unnecessary location request will prevent device to sleep and also drain battery.
  • Stop location service when there is no need of location.
  • Stop orientation change notification when there is no need of notification.
  • You should request fewer update for motion update like accelerometer, etc.
Optimize Notifications:
  • If your app using timer based notification then you should use local notification.
Minimize Peripheral Interaction:
  • While using core Bluetooth to interact with other device, scan device when it is needed.
  • Minimize traffic between the watch and phone; transferring data from watch to phone requires Bluetooth power.
Monitor Energy Use:
  • There is a feature in Xcode that shows the energy use of application. Debug your application and check which part is using more energy and minimize that.
  • Measure energy use by Instrument. Use Energy Diagnostics to measure energy use by application.
  • You can also check energy use of application in normal mode in iPhone. 
    • To achieve this go to Settings >Developer > Logging on your device. 
    • Then tap on logging button.
    • Make energy switch button on.
    • Below down tap on start recording button.
    • Now to import this energy log data. Go to instrument open Energy Diagnostic. 
    • Choose File > Import Logged Data from device
For more detail go to this link


iOS 7 New Feature

1. iOS 7.0 Development Requirements

  • Mac OS X v10.8.3 Mountain Lion Or Later
  • iOS 7 Compatibility
    • iPhone 4 and later
    • iPad 2 and later
    • iPad mini
    • iPod Touch (5th Generation)

2. Control Center
  • Pull from bottom anywhere to access even on lock screen 
  • Easy access to airplane, Wi-fi, Bluetooth, Night mode, rotation, etc… via swipe up from bottom
  • Music Control, AirDrop and AirPlay, Torch, etc…
  • May be customizable 

3. Notification Center
  • Available on lock screen
  • Features - Today-All-Missed
    • Need to know today and peek at tomorrow
    • Missed - What you just missed 
  • Today
    • Overview of day's activity
    • Today's events from calendar
    • Weather today, etc.…
4. Multitasking
  • Smart UI for Multitasking
  • Swipe Up to close app completely
  • Intelligently scheduled updates
  • Example: Updates when charging and connected to wi-fi Saves battery

5. Camera 
  • Still - Filters iPhone 5 and above
  • Video recording at 60 FPS - May be options for 24,30 and 60 FPS
  • Square - Filters iPhone 5 and above
  • Panorama

6. Photos 
  • Collections - Tap collections to see moments - organized according to date and location
  • Moments -
  • Years - Each year holds collections - looks like artwork
  • Nice preview from collections 
7. iCloud
  • Create shared photo stream
  • Streams will have comments 
  • Must have contact with email address in your contacts as well in your friends
  • Shared photo stream will be displayed in Activity view with latest updates
  • Maps bookmark syncing with mac and other iOS devices

8. Airdrop
  • Share photos, videos, passes, contacts and anything else via share button from any app
  • Using Wi-Fi and Bluetooth
  • Transfers are encrypted so highly secured
  • Visibility on/off for near by iOS7 devices or for all devices

9. Safari
  • Swipe to reveal controls else its hidden
  • Swipe left to close a page
  • Sync tabs, which are open on your other devices
  • New tab view 
  • No more limited to 8 tabs
  • Unified smart search provides suggestions 
  • Shared Links - URLs from your twitter timeline 
  • Improved Reading Lists - Simply scroll to next article without going back

10. iCloud Key Chain 
  • Now iCloud can remember password
  • It can also suggest you password, which are hard to guess 
  • Password will be synced to all of your devices
  • Remember credit cards and your name on credit card to make shopping easier
  • 256-bit AES encryption 

11. ITunes Radio [Only Available in U.S.]
  • If you own iTunes Match its ad free otherwise it is comes with ads
  • More than 200-featured stations for listening 
  • Edit on the fly to create your own station
  • History - See what you have heard and can be downloaded from iTunes easily

12. Siri 
  • New look and highly improved new voice
  • German and Spanish voice
  • Faster response 
  • New wave based sound detections
  • Added more sources like Wikipedia, Bing and Twitter
  • Extra Tasks
  • Returning Calls
  • Playing Voicemail
  • Controlling iTunes Radio and more
  • Included web search from Bing right inside siri no more redirects to safari

13. AppStore
  • Find apps near by your location
  • Kids Category
  • Auto Update apps - no more red badges

14. Find my iPhone
  • Activation Lock 
  • Active iPhone using your apple ID and password only

15. iOS in the car
  • Siri Eyes free integration
  • Make Phone calls, access music, send and receive messages, get Directions
  • Dictate to reply message
  • Displays traffic conditions and ETA (Estimated time of arrival) when you are leaving home for work or vice versa

16. Inclinometer
  • Measures angle of slope with regards to gravity
  • Can be used instead of altimeter
  • Tracks up and down movement
  • Difference: It measures up and down while accelerometer is for left and right

17. Wi-Fi Hot Spot 2.0
  • Automatically check for your Wi-Fi subscriber like AT&T and connects when you are in range 
  • Faster Internet access and fewer bandwidth constraints

18. New Maps
  • Turn by turn walking directions
  • Keep your phone in pocket and eyes on the road you will be notified while taking turns
  • Night mode for Maps - not much 

19. Inter App Audio
  • Apps can register their audio streams to share with other apps
  • Series of apps could publish audio streams of instrument tracks while another uses the combination of these to compose a song
  • Remote launching other registered inter app audio apps and more….

20. Maps
  • New Directions API
  • Guide user to destinations from within your app
  • Rotate and move around map in 3D using updated views and controls
  • More controls to map overlays

21. Weather App
  • New stunning UI
  • Check weather in multiple cities with beautiful animations
  • A detailed forecast for today and tomorrow and the weather for the next five days
  • Check the weather of one location or all of them at once.


 Other Features
  • Notification Sync across all your iOS devices
  • Phone, FaceTime and Message blocking
  • FaceTime audio call
  • Tencent Weibo improved
  • Handwriting recognition for multiple Chinese characters
  • Italian, Korean, Dutch speakers as well as Chinese - English Bilingual dictionary
  • Transfer App via iTunes Connect
  • Long MMS support - May be longer character count
  • PDF Annotations - 
    • Added annotations to PDF can be viewed 
    • Very useful in iBooks and other reader apps
  • Chat Options right in contact - iMessage
  • 60 FPS video recording
  • Folders Expanded
  • Paging within folders to stores hundreds of apps
  • Per App VPN
  • App Store Volume Purchase - 
    • This may be a way for developers or apple to offer volume purchase rates to schools, perhaps with "Promo codes" that work for a large number of users.
  • Smart Download of TV Episodes
  • Enterprise single sign-on - Not sure but may be single ID and password for multiple users on same enterprise network
  • Granular Cellular Data Tracking
  • Dynamic Wallpapers
  • New smart Mailboxes - Improved Mail search
  • Do Not Track option in Safari - A way to tell advertisers on the web to not track your browsing activities, is now included in mobile Safari and can be enabled with the flip of a switch.
  • The cellular bars are now dots
  • The battery meter is slightly larger and has a flashing lightning bolt NEXT to it when it charges. 
  • The App Store now has a Wishlist feature where you can add apps to the Wishlist to purchase later.
  • In the Facetime app, the front facing camera is turned on and can be seen behind the white background in all three tabs (favorites, recents, contacts).
  • Favorites in the Phone app can now show contact photos via Settings.
  • There's now an Attachments mailbox in the Mail app that filters emails that contain... attachments.
  • You can click on time/date strings in the Messages app to create an appointment in the Calendar app (strings like "tomorrow at 7:30", etc.)
  • When you exit out of a folder it automatically reverts back to the first screen when you open it again
  • Streamline MDM (Mobile Device Management) enrollment
iOS 7 SDK
  • 1500 new API
  • Sprite Kit - 2D and 2.5D game making with super fast power efficient framework including physics
  • Ranking style leader-boards - Authenticate players and share game scores and achievements 
  • UI Dynamics - ability to add realistic motion to apps.
  • Inter-app Audio
  • Push Updates
  • Background asset downloads - Download even if app is not running at scheduled daytime
  • Directions API
  • iBeacons - Bluetooth Low Energy profile for Micro Location - precise location inside building
    • Low Cost transmitters can notify nearby iOS 7 devices of their presence
    • Very useful with Passbook
    • Example usages
      • Trail markers in park
      • Treasure hunt guide
      • Product displays in stores
      • Vouchers for cup of coffee
      • Discount deals in stores
      • Event and museum ticket deals
  • Guided Access API
  • Custom Video Compositors
  • Barcode Scanning - May be in passbook 
  • Dynamic type size
  • Peer to peer connectivity
  • New multitasking API
  • Third Party Game Controllers - Support for third party game controller providers
  • New color palettes

Limitations
  • Panorama - iPhone 4S and later
  • Square, Video and Swipe to capture - iPhone 4 and Later
  • Filters in Camera or Real-time Filters - iPhone 5 and later
  • Filters in Photos - iPhone 4 and later
  • Air Drop from iPhone 5 and later
  • Siri updates - iPhone 4S and later, features vary by user's location

Wednesday, March 9, 2016

Top most asked iOS Question interview
  1. What is category? Can you have properties or ivars in a category?
  2. What is the output binary format? Explain .app structure.
  3. What are the CPU architectures supported by iOS devices?
  4. What iOS version onwards ARC can be used?
  5. Can we support same application for iPhone3GS and iPhone5? Why not?
  6. Can I write some C++ function in same .m file? Will it compile? If no, what changes should I do to compile it?
  7. What are the types of iOS binaries you can create using XCode? (.app, .ipa, .a, .framework)
  8. Can a static library (.a) contain resources like images, sound files etc?
  9. What is bundle?
  10. Explain application life cycle.
  11. What is responder chain?
  12. Tell me hierarchy of UIButton.
  13. Why create a custom view?
  14. Why UIControl is provided if we can create custom UIView?
  15. What are lifecycle events of UIViewController?
  16. Difference between viewDidLoad and viewDidAppear?
  17. Is UIKit thread safe?
  18. Why do we override drawRect: method?
  19. What are layers?
  20. What are various singleton instances provided by frameworks? (UIApplication, NSFileManager, NSUserDefaults, etc.)
  21. What is NSUserDefaults? What type of data can we store there?
  22. How do you check if your code has memory leaks?
  23. What does static analyser do?
  24. What are different Instruments Xcode supports for app profiling?
  25. Concepts of notification center, local and remote notifications.
  26. Have you uploaded app on Appstore? What is the process?
  27. Difference between Developer and Enterprise Developer accounts?
  28. Common reasons for app rejection from Appstore review process?
  29. UITableView cell reuse. How to get it working (w/ or w/o XIB)? How would you implement reuse on a UIScrollView?
  30. What is protocol? What is formal and informal protocol?
  31. What is ARC? Is it garbage collection?
  32.  Difference between atomic and nonatomic properties?
  33.  Difference between strong and retain?
  34. What is delegate? Can delegates be retained?
  35.  What is retain cycle?
  36.  Does ObjectiveC have multiple inheritance? Why not? How to imitate multiple inheritance?
  37.  What is class extension? Why do we require them?
  38.  Who calls dealloc method? Can we implement dealloc in ARC? If yes, what is the need to do that?
  39.  Can you write setter method for a retain property?
  40.  Can you write a singleton class in ObjectiveC?
  41.  What is GCD? What are advantages over NSThread?
  42.  What is NSOperation and NSOperationQueue?
  43.  What are NSAutoreleasePool? When to use them?
  44.  How does dispatch_once manages to run only once?
  45. What are blocks?
  46.  Does a thread created using performSelectorInBackground:withObject: creates its own autorelease pool?
  47.  ObjectiveC is dynamic language? True/False, explain.
  48. Explain UIApplicationMain?
  49.  What is the output binary format? Explain .app structure.