Wednesday, October 22, 2014

iOS: Health App and HealthKit Part:- 2

Hi Friends,

please check iOS: Health App and HealthKit Part:- 1 for information regarding iOS 8  Health app and it's features.
Now some information about HealthKit.

HealthKit:


By using HealthKit in your applications which contains Health and fitness information, can share informations with inbuilt Health app.

User can share his medical information from the Health app.For example you can allow the data from your weight tracking app to be automatically shared with your doctor.for that you have to choose which data to be shared with which person and you can turn off this sharing any time.

You can read data from Health app and write it to any other app. You can share your health information to Health application by any other applications which uses HealthKit. 

HealthKit also works with fitness and health related devices.The HealthKit data is not saved to iCloud or synced across multiple devices.The data is only kept locally in the user's device.

Benefits: 

HealthKit makes easier to share data between apps. developers  do not need to write code for each app.They can begin sharing automatically through healthKit store with HealthKit apps.

Apps can access wider range of data which gives each app a complete view of the user's health and fitness requirements.

Separating data collection, data processing and socialization:- For example a group of friends could participate in a daily cycling challenge.Each can use his hardware device or any tracking app, but t hey could all still use the same social app for the challenge.

HealthKit's Design:

All objects in the HealthKit store are subclasses of the HKObject class.Each object has the following properties:

  •  UUID:- It is a unique identifier for that particular entry.
  • Source:-  The source of the data. The source can be a device that directly saves data into HealthKit, or an app. HealthKit automatically sets each object’s source when the object is saved to the HealthKit store. This property is available only on objects retrieved from the store.
  • Metadata:-  A dictionary containing additional information about the entry. 
All objects in the HealthKit store are subclasses of the HKObject class.Each object has the following properties:

HealthKit objects can be divided into two groups: - 1) Characteristics and 2) Samples

Characteristics objects represent data that can't change. like birthdate,  blood type, biological sex.Your app can's save characteristic data.User must enter or modify using Health App.

Samples objects are subclasses of HKSample class and they have following properties. 

  • Type:-  The sample type. Eg, this could include a sleep analysis sample, a height sample, or a step count sample.
  • Start date:- The starting time for the sample.
  • End date:- The ending time for the sample. If the sample represents a single point in time, the end time should equal the start time. If the sample represents data collected over a time interval, the end time should occur after the start time.
Samples can further partitioned into:
       
  • Category samples:- There is only one type of category sample, sleep analysis. 
  • Quantity samples:-  These samples represent data that can be stored as numeric values. These include the user’s height and weight, as well as other data such as the number of steps taken, the user’s temperature, and their pulse rate. 
  • Correlations:- These samples represent composite data—data that contains one or more samples. In iOS 8.0, HealthKit uses correlations to represent food and blood pressure. You should always use a correlation when creating food or blood pressure data. 
  • Workouts:-  Workouts represent some sort of physical activity, like running, swimming, or even play. Workouts often have typeduration,distance, and energy burned properties. 


Please check HealthKit demo in iOS: Health App and HealthKit Part:- 3 which will show you how to create a HealthKit application, how to perform read-write operations with it.


Thursday, October 16, 2014

iOS: Health App and HealthKit Part:- 1

Health App and HealthKit



In iOS 8 apple has added health related features which bring your personal measurements to your phone and your iPhone with iOS 8 is capable of monitor your personal health statistics.

For iOS 8 , Apple has created one application called "Health". This Health application will track you and store your health and fitness information.

This new feature announced in WWDC (Worldwide Developers Conference) 2014.


Health App:



Health application that collects your personal biometric data.In this app you can see all personal information about you in one place. You can share it with other health related apps.

By opening Health application you can view calories burned, cholesterol levels, heart rate and blood sugar.Health app can collects all this data.



As per example if you want to track your Sleep Analysis or Cycling Distance. You can do it by Health app and also see on dashboard.





By setting "Show on Dashboard" you can get it in Dashboard.



You can create an emergency card which stores health information life blood type , allergies , Medical Note, Medications. emergency contacts,weight, height, birthrate etc.






  

This emergency card is called Medical ID. This Medical id can be accessible from the Lock screen so it can accessed in an emergency.




                                             
Lets discuss about HealthKit in next part.


Sunday, October 12, 2014

It's all about Gesture Recognizers

Hi Friends , I am going to discuss here Gesture Recognizers and its effect on Views for iOS.

So Lets start,

What is Gesture Recognizers ? 


Basically it is something related “Events Handling”. In one sentence Gesture Recognizers are objects which you can attached to your view,scrollview,buttons,Image view etc.

What is the use of Gesture Recognizers ? 

I am guessing that you all are familiar with UIButton and its action events like touchUpInside , touchDown etc.So something should be there to notify touchDown or touchUpInside events.

Gesture Recognizers do same thing for us with any Views.It interpret touches to determine specific gesture like swipe,pinch,rotation. You can assign Gesture to any view and they send action to particular target object. Object is your view’s view controller.

So in simple words you can tap,swipe,double tap,pinch,long press, rotate on any view and get notification with the help of Gesture Recognizers.


Lets Discuss about some Gestures, with less description :) and more examples
So I have a view  and I want to check gestures on this view .


Single Tap: 

    UITapGestureRecognizer *singleTapGesture = [[UITapGestureRecognizer alloc] init];

    if([self respondsToSelector:@selector(handleSingleTapGesture:)]) {
        [singleTapGesture addTarget:self action:@selector(handleSingleTapGesture:)];
    }

    [view addGestureRecognizer:singleTapGesture];


- (void)handleSingleTapGesture:(UITapGestureRecognizer *)tapGestureRecognizer{
}

Double Tap: 

    UITapGestureRecognizer *doubleTapGesture = [[UITapGestureRecognizer alloc] init];

    doubleTapGesture.numberOfTapsRequired = 2;

    if([_delegate respondsToSelector:@selector(handleDoubleTapGesture:)]) {
        [doubleTapGesture addTarget:_delegate action:@selector(handleDoubleTapGesture:)];
    }

    [view addGestureRecognizer:doubleTapGesture];

- (void)handleDoubleTapGesture:(UITapGestureRecognizer *)tapGestureRecognizer{
}

Long Press: 

    UILongPressGestureRecognizer *longpressGesture = [[UILongPressGestureRecognizer alloc] init];
    longpressGesture.minimumPressDuration = 0.5;
    
    if([_delegate respondsToSelector:@selector(handleLongpressGesture:)]) {
        [longpressGesture addTarget:_delegate action:@selector(handleLongpressGesture:)];
    }

    [view addGestureRecognizer:longpressGesture];

- (void)handleLongpressGesture:(UILongPressGestureRecognizer *)longpressGestureRecognizer{
}

Left Swipe: 

    UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] init];

    swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;

    if([self respondsToSelector:@selector(slideToLeftGesture:)]) {
        [swipeLeft addTarget:self action:@selector(slideToLeftGesture:)];
    }

    [view addGestureRecognizer:swipeLeft];

- (void)slideToLeftGesture:(UISwipeGestureRecognizer *)swipeGestureRecognizer{
}


Right Swipe: 

    UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] init];

    swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
    
    if([self respondsToSelector:@selector(slideToRightGesture:)]) {
        [swipeRight addTarget:self action:@selector(slideToRightGesture:)];
    }
    
    [view addGestureRecognizer:swipeRight];

- (void)slideToRightGesture:(UISwipeGestureRecognizer *)swipeGestureRecognizer{
}


Up Swipe: 

    UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] init];

    swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
    
    if([self respondsToSelector:@selector(slideToUpGesture:)]) {
        [swipeUp addTarget: self action:@selector(slideToUpGesture:)];
    }
    
    [view addGestureRecognizer:swipeUp];

- (void)slideToUpGesture:(UISwipeGestureRecognizer *)swipeGestureRecognizer{
}

Down Swipe: 

    UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] init];
    swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
    
    if([self respondsToSelector:@selector(slideToDownGesture:)]) {
        [swipeDown addTarget:self action:@selector(slideToDownGesture:)];
    }
    
    [view addGestureRecognizer: swipeDown];

- (void)slideToDownGesture:(UISwipeGestureRecognizer *)swipeGestureRecognizer{
}

Pan:

    UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] init];

    if([self respondsToSelector:@selector(moveViewWithGesture:)]) {
        [panGesture addTarget:self action:@selector(moveViewWithGesture:)];
    }

    [view addGestureRecognizer:panGesture];

- (void)moveViewWithGesture:(UIPanGestureRecognizer *)panGestureRecognizer{
}

Pinch:

    UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc] init];

    if([self respondsToSelector:@selector(handlePinchGesture:)]) {
        [pinchGesture addTarget:self action:@selector(handlePinchGesture:)];
    }
    
    [view addGestureRecognizer:pinchGesture];


-(void)handlePinchGesture:(UIPinchGestureRecognizer *)pinchGestureRecognizer{
}

Rotate: 

UIRotationGestureRecognizer *rotationGesture= [[UIRotationGestureRecognizer alloc] init];
    
    if([self respondsToSelector:@selector(handleRotationGesture:)]) {
        [rotationGesture addTarget:self action:@selector(handleRotationGesture:)];
    }
    
    [view addGestureRecognizer:rotationGesture];

-(void)handleRotationGesture:(UIRotationGestureRecognizer *)rotationGestureRecognizer{
}