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

  • SEARCH
  • Home
  • 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 7689387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:09:15+00:00 2026-05-31T20:09:15+00:00

The following are methods that I am using to retrieve data from a server

  • 0

The following are methods that I am using to retrieve data from a server while displaying a UIActivityIndicator. I’m trying to put these methods in the app delegate and then call them from other classes, but I don’t know how to return my JSONData. Can anybody help with this?

 -(void)startProcess:(NSString *)buildURL{


UIActivityIndicatorView *aInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActionSheetStyleBlackTranslucent];

[aInd setFrame:CGRectMake(0, 0, 50, 50)];
[aInd startAnimating];

// then call the timeCOnsumingmethod in separate thread.
[NSThread detachNewThreadSelector:@selector(getData:) toTarget:self withObject:buildURL];
} 

- (void)getData:(NSString *)buildURL{


NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

// Query our database for a restaurant's menus
NSURL *url = [NSURL URLWithString:buildURL];
NSError *e;
NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&e];

NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding];
// NSError *error = nil;

[self performSelectorOnMainThread:@selector(endProcess:) withObject:jsonData waitUntilDone:YES];
[pool release];

//return jsonData;
}

- (IBAction)endProcess:(NSData *)jsonData{
// ??????????
return jsonData;
}
  • 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-05-31T20:09:17+00:00Added an answer on May 31, 2026 at 8:09 pm

    Not sure why got downvoted but your approach is all wrong. Here’s what you want to do:

    • Add the UIActivityIndicatorView
    • Use NSURLConnection to asynchronously retrieve the data
    • Use NSJSONSerialization to decode the received JSON into a NSDictionary or NSArray
    • Remove the UIActivityIndicatorView

    Your best bet would be to implement this as a separate class that takes a delegate object. You could implement a delegate protocol to indicate states like ‘started network activity’ (which your delegate could use to add a spinner view), and ‘received data’ (which would pass the decoded object back to the delegate – the delegate could then remove the spinner).

    One of the benefits of this approach is you can easily set it up so that the connection/request is canceled when the object deallocs. Then you just store the request object as a property on your delegate, and when your delegate goes away, it deallocs the request, which cancels/cleans up properly.

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

Sidebar

Related Questions

I'm trying to retrieve list data from a Sharepoint 2010 server using the webservice
I have an .aspx file that outputs an image using the following methods: Server.MapPath(somefile.png)
Hello I have the following code to retrieve data from my db using nhibernate
UPDATE: This is the CFC code that I'm using to retrieve the data. I'm
I'm using the following code to request data from an ASP.net MVC application. I'm
I'm using domdocument() to retrieve data from a web page, and I want to
Currently I am able to retrieve data from a MySQL db by using HTTP
I am using C# to write a method that returns the following information about
I have a partial that renders a select box using the following method: <%=
I’m after some C# code that will have the following methods that will return

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.