krishna03

Main parse

Apr 25th, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. @interface Headparse : NSObject {
  2.  
  3. NSMutableData *responseData;
  4. }
  5. @property (retain, nonatomic) NSMutableData *responseData;
  6. +(NSMutableArray *) getArrayFromDB : (NSString *)actionType :(NSMutableDictionary *) postData;
  7. +(NSMutableArray *) getArrayFromDB : (NSString *)actionType;
  8. +(NSMutableArray *) getArrayFromUrl: (NSString *)actionType;
  9. +(NSMutableArray *) getArrayFromUrl:(NSString *)actionType withData:(NSMutableDictionary *) postData;
  10. @end
  11.  
  12.  
  13. #import "Headparse.h"
  14. #import "JSON.h"
  15. #import "SBJsonParser.h"
  16. #import "Dataoperation.h"
  17.  
  18. @implementation Headparse
  19. @synthesize responseData;
  20.  
  21.  
  22. +(NSMutableArray *) getArrayFromUrl: (NSString *)actionType
  23. {
  24. NSMutableData *responseData1= [NSMutableData data] ;
  25. responseData1 = [NSMutableData dataWithContentsOfURL:[NSURL URLWithString:actionType]];
  26. // NSLog(@"%@",responseData1);
  27. NSString *responseString1 = [[NSString alloc] initWithData:responseData1 encoding:NSUTF8StringEncoding];
  28. //NSLog(@"REs:-->%@",responseString1);
  29. //[responseData1 release];
  30. responseData1 = nil;
  31. NSMutableArray *responseArray = [[NSMutableArray alloc]init];
  32. responseArray = (NSMutableArray *)[responseString1 JSONValue];
  33. // NSLog(@"ghfchfvghv%@",responseArray);
  34. [responseString1 release];
  35. return responseArray;
  36. }
  37. +(NSMutableArray *) getArrayFromUrl:(NSString *)actionType withData:(NSMutableDictionary *) postData
  38. {
  39. int x=1;
  40. for(id key in [postData allKeys])
  41. {
  42. if([postData count]==x)
  43. {
  44. actionType = [actionType stringByAppendingFormat:@"%@=%@",key,[postData valueForKey:key]];
  45. }
  46. else {
  47. x++;
  48. actionType = [actionType stringByAppendingFormat:@"%@=%@&",key,[postData valueForKey:key]];
  49. }
  50. }
  51. NSMutableData *responseData1= [NSMutableData data];
  52. responseData1 = [NSMutableData dataWithContentsOfURL:[NSURL URLWithString:actionType]];
  53. NSString *responseString1 = [[NSString alloc] initWithData:responseData1 encoding:NSUTF8StringEncoding];
  54. responseData1 = nil;
  55. NSMutableArray *responseArray = [[NSMutableArray alloc]init];
  56. responseArray = (NSMutableArray *)[responseString1 JSONValue];
  57. [responseString1 release];
  58. return responseArray;
  59. }
  60.  
  61. +(NSMutableArray *) getArrayFromDB : (NSString *)actionType :(NSMutableDictionary *) postData{
  62.  
  63. // NSLog(@"ActionFile%@",[actionType description]);
  64. // NSLog(@"PostedData%@",[postData description]);
  65. NSString *sourceFile = [NSString stringWithFormat:@"%@",actionType];
  66. NSMutableDictionary *data = [[NSMutableDictionary alloc]init];
  67. [data addEntriesFromDictionary:postData];
  68. NSMutableArray *result=[[NSMutableArray alloc]init];
  69. result = [Dataoperation getData:sourceFile :data];
  70. // NSLog(@"resultData%@",[result description]);
  71. return result;
  72. }
  73.  
  74.  
  75. +(NSMutableArray *) getArrayFromDB : (NSString *)actionType{
  76.  
  77. NSString *sourceFile = [NSString stringWithFormat:@"%@",actionType];
  78. NSMutableArray *result_Array = [[NSMutableArray alloc]init];
  79. result_Array = [Dataoperation getData:sourceFile :@""];
  80. // NSLog(@"%@",[result_Array description]);
  81. return result_Array;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment