0

I am parsing JSON data from URL. The URL has data but array returns null in code here is the code which i am using for parsing.

      tempArray =[[DataController staticVersion] startParsing:[NSString     stringWithFormat:@"http://ec2-54-84-162-129.compute-1.amazonaws.com/hotelcms/getActivityHotel.php?ActivityDate=Sunday March 15th&ActivityNameID=1"]];

 NSLog(@"Temp Array is %@",tempArray);

Here is the DataController Class

    @interface DataController : NSObject {

     }
    + (id)staticVersion;
    - (NSMutableArray *) startParsing:(NSString *)theURLString;
    @end

   @implementation DataController

   DataController *theInstance;
  + (id)staticVersion                                                                         


  {

    if(!theInstance){
    theInstance = [[DataController alloc] init];
    }
  return theInstance;
  }


 - (NSMutableArray *) startParsing:(NSString *)theURLString {

   NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",theURLString]];
  NSString *fileContent= [NSString stringWithContentsOfURL:url];
  SBJSON *parser = [[SBJSON alloc] init];  
  NSDictionary *data = (NSDictionary *) [parser objectWithString:fileContent error:nil];  
NSArray *items = (NSArray *) data ;  
return items;
}
 @end
2
  • 1
    Why are you calling [NSString stringWithFormat: @"%@", theString]]? That's utterly, utterly pointless. Commented Apr 16, 2015 at 10:37
  • The data you are parsing is not in proper JSON Format. For it you need to use xml parsing Commented Apr 16, 2015 at 10:42

1 Answer 1

1

The response from that URL is not a valid JSON object. See if you can remove the erroneous "Sunday March 15th" from the start of the response.

Sign up to request clarification or add additional context in comments.

1 Comment

It's amazing how helpless people are with the slightest problem. He should have figured that out himself within 10 seconds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.