Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8599637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:26:23+00:00 2026-06-12T01:26:23+00:00

I have a webmethod wich returns a lot of json data. I have a

  • 0

I have a webmethod wich returns a lot of json data.
I have a separate class where I fetch my data. In this class I do the following.

+ (NSDictionary *)executeGenkFetch:(NSString *)query
{
    query = [NSString stringWithFormat:@"%@&format=json&nojsoncallback=1", query];
    query = [query stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    // NSLog(@"[%@ %@] sent %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), query);
    NSData *jsonData = [[NSString stringWithContentsOfURL:[NSURL URLWithString:query] encoding:NSUTF8StringEncoding error:nil] dataUsingEncoding:NSUTF8StringEncoding];
    NSError *error = nil;
    NSDictionary *results = jsonData ? [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers|NSJSONReadingMutableLeaves error:&error] : nil;
    if (error) NSLog(@"[%@ %@] JSON error: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), error.localizedDescription);
    // NSLog(@"[%@ %@] received %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), results);
    return results;
}

+ (NSArray *)GetNieuws
{
    NSString *request = [NSString stringWithFormat:@"http://www.krcTest.be/mobile/json/request/webmethod"];
    return [[self executeGenkFetch:request] valueForKeyPath:@"news.title"];
}

Now I have a button to do a NSLog with the data. Here you see the action behind the button.

- (IBAction)testFetch:(id)sender {
    NSArray *nieuws;
    nieuws = [GenkData GetNieuws];
    NSLog(@"%@",nieuws);

}

In my Log always shows up this.

2012-10-01 10:52:16.379 RacingGenk[13434:c07] (null)

Could anybody help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:26:24+00:00Added an answer on June 12, 2026 at 1:26 am

    Your endpoint gives a DNS error which may explain why you have no data, however assuming you might have anonomised it there are plenty of ways to debug this yourself.

    Start by not chaining method calls together like this;

      NSData *jsonData = [[NSString stringWithContentsOfURL:[NSURL URLWithString:query] encoding:NSUTF8StringEncoding error:nil] dataUsingEncoding:NSUTF8StringEncoding];
    

    Instead prefer (and note in particular you were missing the error response from one call the way you were doing it);

       NSError *error = nil;
       NSURL *request = [NSURL URLWithString:query];
       NSLog(@"Outgoing Request: %@",[request description]);
       NSString *response =  [NSString stringWithContentsOfURL:request encoding:NSUTF8StringEncoding error:nil];
    
       if (error) { 
           NSLog(@"ERROR: Unable to get response %@",[error localizedDescription]); 
       }
    
       NSLog("@Synchronous Response: %@",response);
    
       NSData *jsonData = [response dataUsingEncoding:NSUTF8StringEncoding];
       NSDictionary *results = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers|NSJSONReadingMutableLeaves error:&error];
    
       if (error) { 
           NSLog(@"ERROR: Unable to parse JSON %@",[error localizedDescription]); 
       }
    

    By not chaining your method calls together, you can now print intermediate results to see what the problem is, and you can also use breakpoints to step through it much better too.

    While I’m here, it’s odd to have methods like this as class methods rather than instance methods and you should be aware that synchronous network use like this will kill your UI performance unless you are doing it on another thread which I suspect you are not. You may wish to look at the asynchronous network methods of NSURLConnection instead.

    I haven’t syntax checked the above as I’m typing this on a PC, but it should point you in the right direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following webservice: [webmethod] public string MakeReservation(?? PassengersInfo)//what data type use for PassengerInfo
I have an asp.net asmx webmethod that returns the following response: <?xml version=1.0 encoding=utf-8?>
I have a simple web service like this: @WebService public class MyWebService { @WebMethod
I have a page with this method in CreateTicket.aspx.cs: [WebMethod()] public static string Categories()
I have a JSON response that is formatted from my C# WebMethod using the
I have an ASP.NET 2.0 web method with the following signature: [WebMethod] public QueryResult[]
I have a WebMethod that looks like this which is used to populate a
i have a webmethod in my webservice public class Service : System.Web.Services.WebService { [WebMethod]
I have a webmethod inside a webservice that calls another webservice to get data
I have the following code: [WebMethod] [SoapHeader(_webServiceAuth)] public User GetUser(string username) { try {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.