Sunday, 27 November 2016

Get list of all Videos

ALAssets library has deprecated in iOS9, and Apple introduce new framework  'Photos Framework' for retrieve assets for display and playback, edit image or video content, or work with collections of assets such as album, moments, and iCloud Shared Album.

Features:
1. Fetching objects and requesting changes
    Class's instance of Photos framework model retrieve assets(images, videos,  and Live Photos), collections of assets(albums or moments), and list of collections(such as album folder or moment clusters). There objects are read only, immutable and contain metadata only.
2. Change observing.
3. Support for Photos app features.
4. Assets and thumbnail loading and caching.
5. Assets content editing.

For details about Photos framework Click here

In this part of blog we will fetch all video assets from device(Photos app).
PHAssets:
All images, videos and live photos in Photos library represented by an instance of PHAssets.
 Instances of PHAsset are immutable.

PHFetchResult:
An ordered list of assets or collections returned from Photos fetch methods.
Photos provide all assets in the in a fetch result.

PHImageManager:
PHImageManager provide methos for retrieving and generating preview thumbnails and full-size image or video data associated with assets instance.

Below chunk of code for retrieving list of video' assets from Photos application.

-(void) getAllVideoAssets{
    NSMutableArray *assets = [[NSMutableArray alloc] init];
    //Fetch all video assets from Photos
    PHFetchResult *assetResults = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeVideo options:nil];
    //get all assets
    for (PHAsset *asset in assetResults){
        NSLog(@"asset type = %zd", asset.mediaType);
        [assets addObject:asset];
    }
    self.allVideoslistArray = [[NSMutableArray alloc] init];
    //create an instance of PHImageManager
    PHImageManager *manager = [PHImageManager defaultManager];
    for(PHAsset *asset in assets){
        //block of code for represent video assets
        [manager requestAVAssetForVideo:asset options:nil resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
            if ([asset isKindOfClass:[AVURLAsset class]]) {
                NSURL *url = (NSURL *)[[(AVURLAsset *)asset URL] fileReferenceURL];
                UIImage *thumbnail = [self createThunbnailImage:url];
                [self.allVideoslistArray addObject:@{@"VideoUrl":url,@"ThumbnailImage":thumbnail, @"VideoAsset":asset}];
            }
        }];
    }//end for loop
}

Sunday, 20 November 2016

Text Animation

A well design  user interface is a key feature of an application.  A end user only interact with UI part an application, so making an  attractive user interface  force user to play with application.
A small small effect like animation help to improve interface design.

In this blog, i am going to display text message with animations.
Click here for download "TextAnimationView" classes.

Create a new project(TextAnimationApplication).
and add downloaded classes to project

Now go to ViewController.m class and import "TextAnimationView.h" file
and declare a variable

TextAnimationView *textAnimationView;                                                        

define below method to add TextAnimationView to ViewController's view

-(void) addTextAnimationView{
//initialize instance
    textAnimationView = [[TextAnimationView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 100) withMessage:@"It's a sample marquee message."];
    [self.view addSubview:textAnimationView];

//Default text appearance animation
    [textAnimationView displayMessageViewWithPresentationType:AnnouncementViewPresentWithCenterAnimation withSpinAnimation:YES];
}


In ViewController.h class declare an IBAction method

-(IBAction)buttonAction:(UIButton *)sender;


Now Switch to main.storyboard file and add UIButtons for different different animations.

In the sample project i added 10 buttons for display text message with 10 different-different animation. Add all buttons with declared method with TouchUpInside event.

Define IBAction method in ViewController.m, file

-(IBAction)buttonAction:(UIButton *)sender{
    switch (sender.tag) {
        case 1:
//display text with scale transform           

[textAnimationView displayMessageViewWithPresentationType:TextAnimationViewPresentWithCenterAnimation withSpinAnimation:YES];
            break;
        case 2:

// display text animation view from top of the screen to declared frame with simple animation.
            [textAnimationView displayMessageViewWithPresentationType:TextAnimationViewPresentWithTopAnimation withSpinAnimation:NO];
            break;

         case 3:
// display text animation view from left of the screen to declared frame with spin animation.
             [textAnimationView displayMessageViewWithPresentationType:TextAnimationViewPresentWithLeftAnimation withSpinAnimation:YES];
            break;
        case 4:

// display text animation view from alpha value animation with spin animation.       
     [textAnimationView displayMessageViewWithPresentationType:TextAnimationViewPresentWithAlpha withSpinAnimation:YES];
            break;
        case 5:

// display text animation view from the bottom of the screen to declared frame with spin animation.
             [textAnimationView displayMessageViewWithPresentationType:TextAnimationViewPresentWithBottomAnimation withSpinAnimation:YES];
            break;
        case 6:

// display text animation view from right of the screen to declared frame with out spin animation.
             [textAnimationView displayMessageViewWithPresentationType:TextAnimationViewPresentWithRightAnimation withSpinAnimation:NO];
            break;
        case 7:

// display text animation view with marquee animation from right
             [textAnimationView setTextMarquee:YES withDirectionType:TextMarqueeFromRight];
            break;
        case 8:

// display text animation view with marquee animation from left
             [textAnimationView setTextMarquee:YES withDirectionType:TextMarqueeFromLeft];
            break;
        case 9:

// display text animation view with marquee animation from Top            [textAnimationView setTextMarquee:YES withDirectionType:TextMarqueeFromTop];
            break;
        case 10:

// display text animation view with character animation(one by one character animation)
             [textAnimationView displayTextWithTypingAnimation:@"It's a sample marquee message."];
            break;
           
        default:
            break;
    }
}


Now run the project and click on buttons for display text message with animations.
Click here for download sample project.


Sunday, 13 November 2016

Analyz Crash Reports



When an application crashes on an iOS device, a "crash report" is created and stored on the device. Crash reports describe the conditions under which the application terminated, in most cases including a complete stack trace for each executing thread, and are typically very useful for debugging issues in the application.

Exception codes:

In the crash log is a line that starts with the text Exception Codes: followed by one or more hexadecimal values. These are processor-specific codes that may give more information on the nature of the crash.

 The exception code 0xbaaaaaad indicates that the log is a stackshot of the entire system, not a crash report. To take a stackshot, push the home button and any volume button. Often these logs are accidentally created by users, and do not indicate an error.
The exception code 0xbad22222 indicates that a VoIP application has been terminated by iOS because it resumed too frequently.
 The exception code 0x8badf00d indicates that an application has been terminated by iOS because a watchdog timeout occurred. The application took too long to launch, terminate, or respond to system events.
The exception code 0xc00010ff indicates the app was killed by the operating system in response to a thermal event. This may be due to an issue with the particular device that this crash occurred on, or the environment it was operated in.
The exception code 0xdead10cc indicates that an application has been terminated by iOS because it held on to a system resource (like the address book database) while running in the background.
The exception code 0xdeadfa11 indicated that an application has been force quit by the user. Force quits occur when the user first holds down the On/Off button until "slide to power off" appears, then holds down the Home button. It's reasonable to assume that the user has done this because the application has become unresponsive, but it's not guaranteed - force quit will work on any application.
For detail information Click here


Thursday, 13 October 2016

Create a bootable USB flash drive in mac

Here i am going to show you, how to create a bootable USB flash drive in mac. In this example i will create a bootable USB flash drive in mac for window installation.

Before begin download ISO image for window. Lots of  online source available for download ISO image for window or you can download from Microsoft software download page.

after completion of download open Terminal.

Type the following command:
$ diskutil list                                                                                                    
above command give the list of all external and internal disk list.
After execution of above above command you can list like below SS






We can see the list of all connected disk. Name is start with disk0, disk1 and so on. Both are internal disk.
Now, connect a USB flash drive to mac. To create a bootable USB drive for a Windows installation, we require a USB drive with the 4 GB of minimum capacity. Larger capacity will be better.
Note: before connect USB drive to mac clear all data from USB drive or format that.
Again  type the previous command and press enter
$ diskutil list                                                                                                          




Now we can see the one more disk(external) in the list. Name of the disk is disk2
Now unmount the external disk.
Unmounting a disk makes it inaccessible by the computer.
Use below command for unmount disk
                                                                                                                          
$ diskutil unmountDisk /dev/disk2                                                                                     
                                                                                                                           
Press enter and we can see the message on terminal
"Unmount of all volumes on disk2 was successful."

Now type the following command

sudo dd if=iso_image_path of=/dev/disk2 bs=1m                                                              

iso_image_path is the location of downloaded window iso image. Get the path of iso image and replace with 'ios_image_path'

Press enter, it will prompt for enter password, enter password and press enter.
It will take some time, may be 30 - 40 mins.

After completion of process it will give message like below image


4145.514462 secs, total time taking for completion of process.

Now eject USB flash disk using following command

$ diskutil eject  /dev/disk2                                                                                                      

Again connect USB disk to mac and can check all files.
Now we have a bootable USB flash drive for window installation.

 

Monday, 10 October 2016

CABasicAnimation

CABasicAnimation provides basic, single-keyframe animation capabilities for a layer property.
CABasicAnimation class animates a layer property between two values, a starting and an ending value. To move a layer from one point to another in its containing window, for example, we can create a basic animation using the keypath position. We give the animation a start value and an ending value and add the animation to the layer.

Here i am going to create a search animation, animation start with a small circle with minimum radius and continue increase the radius and after maximum radius again its start animate the circle from minimum radius.

First create  a Project(SearchActivityIndicatorViewSample)

Now create a new file(SearchActivityIndicatorView) which is subclass of UIView.
We are going to display a animated circle, so for creating a  circle i am going to declare another Class(SearchActivityIndicatorCircleView) inside "SearchActivityIndicatorView".
SearchActivityIndicatorCircleView class also a subclass of UIView.

Ok, Why i am creating a separate class for display a circle?
Answer is, if we want to display more than one circle as a search indicator so we can use multiple instance of that class and we don't need to write code for multiple circle. So by using this approach     we can avoid duplication of code.
 and also declare a property for stroke color inside "SearchActivityIndicatorCircleView Class".

here the code snippet

@interface SearchActivityIndicatorCircleView : UIView
{
   
}
@property (nonatomic, strong) UIColor *strokeColor;
@end


//Implementation 
@implementation SearchActivityIndicatorCircleView

@end


Add the following methods  inside SearchActivityIndicatorCircleView implementation.
-(instancetype) initWithFrame:(CGRect)frame{
    self = [super initWithFrame: frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}


-(void) drawRect:(CGRect)rect{
    //Drawing Code
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSaveGState(context);
    CGContextSetStrokeColorWithColor(context, self.strokeColor.CGColor);
    UIBezierPath *circlePath = [UIBezierPath bezierPath];
    [circlePath addArcWithCenter:CGPointMake(self.bounds.size.width/2, self.frame.size.height/2) radius:MIN(self.frame.size.width, self.frame.size.height)/2 - 5  startAngle:DEGREES_TO_RADIANS(0) endAngle:DEGREES_TO_RADIANS(360) clockwise:YES];
    CGPathRef cgPath = CGPathCreateCopy(circlePath.CGPath);
    CGContextAddPath(context, cgPath);
    CGContextSetLineWidth(context, 1);
    CGContextDrawPath(context, kCGPathStroke);
    CGPathRelease(cgPath);
}


In the first method i override initWithFrame: method for creating a new instance for the class.
and in the second method drawRect: i am creating a circle. Radius of circle is not static, its will depend on the frame size of View.
For calculating the radius i used smallest value between width and height and after getting smallest value reduce 5 from the that, and with the resultant value drawing circle.

Now we have enough code for draw a circle, only need to create a instance of a class and as a sub-view.

Now Switch to SearchActivityIndicatorView.h Class and add following codes.
@interface SearchActivityIndicatorView : UIView
{
    CGFloat maxScale, minScale;
}
@property (nonatomic, assign) BOOL isAnimating;
@property (nonatomic, strong) UIColor *strokeColor;
@property (nonatomic, assign) NSTimeInterval animationDuration;

-(void) startSearching;
-(void) stopSearching;


Now switch to SearchActivityIndicatorView.m and add following code
-(instancetype) init{
    self = [super init];
    if (self) {
        [self initializeDefaultValues];
    }
    return self;
}
-(instancetype) initWithFrame:(CGRect)frame{
   
    self = [super initWithFrame:frame];
    if (self) {
        [self initializeDefaultValues];
    }
    return self;
}
-(void) awakeFromNib{
    [super awakeFromNib];
    [self initializeDefaultValues];
}
-(void) initializeDefaultValues{
    //set animation suration
    self.animationDuration = 1.9f;
    //set default stroke color
    self.strokeColor = [UIColor redColor];
    //set minimum scale
    minScale = 0.3f;
    //set maximum scale

    maxScale = 8.0f;
}


First 3 methods are used to creating new instance for the class
and the last method set default value with the time of new instance creation of class.
Inside this method, i am defining default value for animation duration, color of circle' stroke, minimum and maximum scale for circle view.

Now its time to add SearchActivityIndicatorCircleView
-(void) addCircleSearchView{
   //1. get minimum value between width and height
    CGFloat width = MIN(self.frame.size.width, self.frame.size.height)/4;

   //2. Create an instance of SearchActivityIndicatorCircleView
    SearchActivityIndicatorCircleView *circleSearchView = [[SearchActivityIndicatorCircleView alloc] initWithFrame:CGRectMake(0, 0, width, width)];
    [circleSearchView setStrokeColor:self.strokeColor];
    circleSearchView.center = self.center;
    //3.Add CABasicAnimation for scale view
    CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    //4. set animation duration time
    scaleAnimation.duration = self.animationDuration;
    //5. set repeat count to maximum
    scaleAnimation.repeatCount = CGFLOAT_MAX;
    //6. set minimum value for animation
    scaleAnimation.fromValue = @(minScale);
    //7. set maximum value for animation
    scaleAnimation.toValue = @(maxScale);
    //8. set timing function
    scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];

    //9. add animation to Circle layer
    [circleSearchView.layer addAnimation:scaleAnimation forKey:kSearchScaleAnimationKey];
   //10. add SearchActivityIndicatorCircleView as a subview
    [self addSubview:circleSearchView];
}


Above method create an instance for  SearchActivityIndicatorCircleView, add basic animation for animate a circle and add newly created instances as a subview.
Here step by step explanations:
1. Find minimum value between width and height of frame and divide by 4 means the frame of circle view is 4 times less than SearchActivityIndicatorView.
2. Create an instance of  SearchActivityIndicatorCircleView with the minimum frame size.
3. Create an instance of CABasicAnimation with key "transform.scale".
4. set animation duration, the time require for animation of a circle from minimum scale to maximum scale.
5. set repeat count for animation.
6. set minimum scale or starting scale for animation.
7. set maximum scale for animating the circle.
8. timingFunction: A timing function defining the pacing of the animation.
    CAMediaTimingFunction represents one segment of a function describing a timing curve. The
    function maps an input time normalized to the range [0,1] to an
    output time also in the range [0,1]. E.g. these functions are used
    to define the pacing of an animation over its duration (or over the
   duration of one keyframe). Click here for more detail about CAMediaTimingFunction.

9. add animation to circle layer. CABasicAnimation provide capabilities for animate layer property, so we add animation to layer of circle view.
10. Add circle view as a subview.

We have code for draw a circle, add animation to circle.
So,  now its time to display animation, add below code in SearchActivityIndicatorCircleView.m

-(void) startSearching{
   //check if animation is already started
    if (self.isAnimating) {
        return;
    }

   //set flag value true
    self.isAnimating = YES;

  //add circle
    [self addCircleSearchView];
}


 first we are checking, is animation already started if yes than no need to start animation again.
If no than set the flag value true so we can check animation status later.
and last line send a message to  "addCircleSearchView" method for adding a circle view.




Also write a method for stop animation.
-(void) stopSearching{
    if(!self.isAnimating) {
        return;
    }
    for(UIView *searchView in self.subviews) {
        [UIView animateWithDuration:0.9f animations:^{
            searchView.transform = CGAffineTransformMakeScale(7.0f, 7.0f);
            [searchView setAlpha:0.0f];
        } completion:^(BOOL finished) {
            [searchView.layer removeAllAnimations];
            [searchView removeFromSuperview];
        }];
    }
    self.isAnimating = NO;
}


thats enough.
Now Its time for display our effort to end user.
Switch to ViewController.h class, import SearchActivityIndicatorView

add a property IBOutlet  for SearchActivityIndicatorView
@property (nonatomic, weak) IBOutlet SearchActivityIndicatorView *seachActivityIndicatorView;
and add a IBAction for handle user action.
-(IBAction)handleTapGesture:(UITapGestureRecognizer *)sender;

Now switch to  main.storyboard and drag a UIView from Object library.
Select that view and go to identity inspector and change the class from UIView to SearchActivityIndicatorView
 


Connect IBOutlet to SearchActivityIndicatorView.
Add a Tap Gesture Recognizer  to SearchActivityIndicatorView and connect IBAction method.

Now go to ViewController.m class and method for start animation
-(IBAction)handleTapGesture:(UITapGestureRecognizer *)sender{
   
    if (self.seachActivityIndicatorView.isAnimating == YES) {
        [self.seachActivityIndicatorView stopSearching];
    }
    else{
        [self.seachActivityIndicatorView startSearching];
    }
}


Run the app and tap on the screen, we can see a animated circle on screen.
Click here for complete project.

Saturday, 17 September 2016

Blure Effect

Adding blur effect on the view's corner

User interface play an important role in development of a good application. With the useful and important features, it is necessity of a application to make a attractive and good looking user interface. A well design interface force user to play with application and enjoy the application for a time being.

A small small effect can make the interface better like presenting sub-view  with animation or bounce, adding blur effect in the corner of sub-views.
Here i am going to add blur effect in the corner of sub views.
We can achieve blur effect by using gradient. We are having in-build CAGraientLayer in iOS, so its not a tough  to add blur effect in both corner of a view, because of this CAGraientLayer.
Click here for details of CAGraientLayer.

First create a project and add a UIView as a subview of view in the storyboard or xib file.
Than go to .h file and create a outlet for added UIView.

@property (nonatomic, weak) IBOutlet UIView *horizontalLineViewFirst;

again go to storyboard  or xib file and connect the outlet to added UIView.

Now switch to .m file and add a method

#pragma mark - Add Gradient
-(void) addGrandientlayerToView:(UIView *)gradientView{
    //create a gradient layer
    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
    //set gradient color
    CGColorRef outerColor = [[UIColor colorWithWhite:0.97 alpha:1.0] CGColor];
    CGColorRef innerColor = [[UIColor colorWithWhite:0.72 alpha:0.0] CGColor];

    //set name of the layer
    gradientLayer.name = @"BlurGradientLayer";
    //set color to gradien layer
    gradientLayer.colors = [NSArray arrayWithObjects:(__bridge id)outerColor,(__bridge id)innerColor,(__bridge id)innerColor,(__bridge id)outerColor, nil];
    //set location to each color
    gradientLayer.locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:0.200],[NSNumber numberWithFloat:0.710],[NSNumber numberWithFloat:1.0], nil];
    //set start point for draw a gradient layer
    [gradientLayer setStartPoint:CGPointMake(0, 0.6)];
    //set start point for draw a gradient layer
    [gradientLayer setEndPoint:CGPointMake(1, 0.6)];
    //set bound of the layer
    gradientLayer.bounds = gradientView.bounds;
    //set anchor point of layer to {0,0}
    gradientLayer.anchorPoint = CGPointZero;
    [gradientView.layer addSublayer:gradientLayer];

}


pass the message to above method form viewDidLoad method

[self addGrandientlayerToView:self.horizontalLineViewFirst];

Run the  app,  we can see a blur effect on added subview.





 
We can see a effect similar to above image a horizontal line with blur corners.

Now rotate the simulator or device,  one side of blur effect get misplace,its come in the middle not in both corners. Lets fix the issue

add another method to reset gradient location after orientation

#pragma mark -
#pragma mark Handle Orientation

- (void) handleOrientationChange:(NSNotification *)notification{
    [self resetAllGradientLayer];
}
-(void) resetAllGradientLayer{
    [self resetGradientforView:self.horizontalLineViewFirst];
}
-(void) resetGradientforView:(UIView *)gradientView{
    for (CAGradientLayer *layer in gradientView.layer.sublayers){
        if ([layer.name isEqualToString:@"BlurGradientLayer"]) {
            layer.bounds = gradientView.bounds;
        }
    }
}

 
Add orientation change notification to controller

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOrientationChange:) name:UIDeviceOrientationDidChangeNotification object:nil];

 
Now again run the application and check.
Click here for complete project.

Friday, 2 September 2016

Sqlite Database in ios



Sqlite is an in-process library that implement a self-contained,  serverless,  zero-configuration, transactional SQL database engine. Sqlite is very small and light weight, less than 400kiB fully configured or less than 250 KiB with optional features omitted and its not required a separated server process or system to operate.
Click here for more details.

We can use Sqlite for storage data in iOS Application as a database.
This post is related to get data from two different-different database's tables.

First step is to two get both database path.

So create a method which return db path.

-(NSString *) getDbpathWithName:(NSString *)dbName{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
  
    NSString *documentsDir = [paths objectAtIndex:0];
    return [documentsDir stringByAppendingPathComponent:dbName];
}
     

NSString *firstDbPath = [self getDbpathWithName:@"Firstdb.Sqlite"];

NSString *secondDbPath = [self getDbpathWithName:@"Seconddb.Sqlite"];

//declare a Sqlite database instance
sqlite3 *secondDataBase;

//Open second database
if (sqlite3_open([secondDbPath UTF8String], &secondDataBase)!=SQLITE_OK) {
        NSLog(@"Error to open database = %s",sqlite3_errmsg(userDatabase));
        sqlite3_close(userDatabase);
       
secondDataBase = nil;
        return ;
    }
//write a query for attach first database to second database
 NSString *attachQuery = [NSString stringWithFormat:@"ATTACH DATABASE \"%@\" AS aDB",firstDbPath];

//execute query
    sqlite3_exec(
secondDataBase, [attachQuery UTF8String], NULL, NULL, &error);
    if (error) {
        NSLog(@"Error to Attach = %s",error);
        sqlite3_close(userDatabase);
       
secondDataBase = nil;
    }
Now we have attached both database, and can use to get data from both database's tables.

//Write a query to retrieve data
NSString *queryString = @"Select e.id,  e.name,  e.address, ex.car_allowance. ex.medical_allowance, ex.food_allowance from employee e inner join expenses ex on (e.id == ex.empId)".

Here table 'employee' is in first database and table 'expenses' is in second database, because we need to fetch data from two different table so we are using 'join'.

//Now Prepare statement
sqlite3_stmt *selectStmt;
    if (sqlite3_prepare_v2(
secondDataBase, queryString.UTF8String, -1, &selectStmt, NULL) != SQLITE_OK) {
        NSLog(@"Error to prepare annotation select stmt all comment= %s",sqlite3_errmsg(
queryString));
        sqlite3_finalize(selectStmt);
        sqlite3_close(
secondDataBase);
        selectStmt = nil;
       
secondDataBase = nil;
        return;
    }
Its time to fetch all records 
NSMutableArray *empRecordArray = [[NSMutableArray alloc] init];
   
 while (sqlite3_step(selectStmt)==SQLITE_ROW) {
        NSString *empid = [NSString stringWithFormat:@"%s",(const  char*)sqlite3_column_text(selectStmt, 0)];
        NSString *name = [NSString stringWithFormat:@"%s",(const char*)sqlite3_column_text(selectStmt, 1)];
       NSString *address = [NSString stringWithFormat:@"%s",(const char*)sqlite3_column_text(selectStmt,2)]; 
       NSString *car_allowance = [NSString stringWithFormat:@"%s",(const char*)sqlite3_column_text(selectStmt, 3)]; 
       NSString *medical_allowance = [NSString stringWithFormat:@"%s",(const char*)sqlite3_column_text(selectStmt, 4)]; 
       NSString *food_allowance = [NSString stringWithFormat:@"%s",(const char*)sqlite3_column_text(selectStmt, 5)];
      
     NSDictionary *recordDict = @{@"id":empid, @"name":name, @"address":address, @"CarAllowance":car_allowance,@"MedicalAllowance":@"medical_allowance", @"FoodAllowance":food_aalowance};

[empRecordArray addObject:recordDict];
}//end while loop

NSLog(@"All record : %@", empRecordArray);


Check out more post related to