Thursday, 1 October 2015

how to parsing using some method Ios/Iphone

now use declared some method and implement it..
parsemanager.h
--------------------------------------------------------------------------
//
//  ParseManager.h

#import <Foundation/Foundation.h>
@interface ParseManager : NSObject {

}
+(bool)parseloginurlContent:(NSData *)content;

@end
========================
then use implement of it
parsemanger.m
=================================
//
//  ParseManager.m

#import "ParseManager.h"
#import "ApplicationData.h"



@implementation ParseManager


+(bool)parseloginContent:(NSData *)content
{
    //{"status":"success","userkey":"315061770","phone":"9825198673","customerno":"0","username":"Pratik.bbits@gmail.com","realname":"pratik","licence":"0","total_license":"1","version":"V1","is_valid":"1"}
    NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:content options:0 error:nil];
    NSLog(@"data received: %@", jsonDict);
    if ([[jsonDict valueForKey:@"status"] isEqualToString:@"successful"]) {
        if ([jsonDict count] > 0)
        {
            [ApplicationData sharedInstance].strCustomerName    = [jsonDict valueForKey:@"customername"];
            [ApplicationData sharedInstance].strCustomerNo      = [jsonDict valueForKey:@"customerno"];
            [ApplicationData sharedInstance].strRole            = [jsonDict valueForKey:@"role"];
            [ApplicationData sharedInstance].strStatus          = [jsonDict valueForKey:@"status"];
            [ApplicationData sharedInstance].strUserKey         = [jsonDict valueForKey:@"userkey"];
            [ApplicationData sharedInstance].strUserName        = [jsonDict valueForKey:@"username"];
            [ApplicationData sharedInstance].strVersion         = [jsonDict valueForKey:@"version"];
            [ApplicationData sharedInstance].errorCode          = jSuccess;
        }
    }
    else
    {
        [ApplicationData sharedInstance].errorCode = jFailure;
    }
    return TRUE;
}


@end