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 8844025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:22:57+00:00 2026-06-14T11:22:57+00:00

I’ve been developing an iPhone app, which handed by an experienced developer. I’m just

  • 0

I’ve been developing an iPhone app, which handed by an experienced developer. I’m just an apprentice programmer and still struggling with practical Objective-C/iOS application development (I have learned Java and PHP on my own, but objective-c is nothing like these to me).

Our app is just another “web-centric” (I don’t even know this word is appropriate…) app which heavily relies on server-side operations, making frequent http post request every single time (such as tracking user locations, send messages to another users etc.).

When I was assigned to develop this app, I saw in the code, that every single http request was written inside each method. Each request was done by dispatching another thread, and each action were written for those requests’ response accordingly.

E.g.

-(void) methodA {  
// Making http request headers...  

// Dispatch another thread  
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT , 0);  
dispatch_async(queue, ^{  
  // Send synchronous request and handle the response...  
});

}  

-(void) methodB {  
// Making http request headers...  

// Dispatch another thread  
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT , 0);  
dispatch_async(queue, ^{  
  // Send synchronous request and handle the response...  
});

}  

The codes like above are every where when the app needs to send request to the server.

I’m wondering, why he didn’t create a class that handles http requests.
In Java, you could create a class that make synchronous request to the server:

public class ClassHttpRequest {
     public int makePost {  
        // Send synchronous request and return result...  
     }  
}  

Then make an instance of this class and execute it’s instance method (in this case, makePost) inside a thread:

public class methodA {  

   Thread t = new Thread(new Runnable() {  
         public void run() {   
           public ClassHttpRequest requestHandler = new ClassHttpRequest();  
               if (success == requestHandler.makePost()) {  
                   // Handle response...  
               }  
           }  
         }  
     });

    t.start();  
 }  

Is there any performance penalty or issues in creating a class and let it handles frequent http request in Objective-C? Or, it’s just simply not “recommended” or something? I have heard that, in Objective-C, it is not common to use try-catch statement for exception handling, because it would consume much resources. I do have read several iOS and Objective-C books (and googled), but such kind of “practical” answer for real application development is hard to find, most of the time it’s rather confusing to beginners like me.

I should ask him why he didn’t create a such class, but he’s away now and I couldn’t get in touch with him. Also, I belive that the professionals here in stackoverflow can provide me much more accurate and concise solutions than my predecessor. (I have asked several questions and already got what I wanted to know.)

Thanks in advance.

  • 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-14T11:22:58+00:00Added an answer on June 14, 2026 at 11:22 am

    Normal rules of object-oriented design apply: if it makes sense to represent a HTTP request as a tangible object – in particular, there’s a bunch of boilerplate code that’s necessary and would otherwise be copy-pasted – then it’s probably a good idea to use a class. Otherwise, there’s no need. Though in this specific case, is there a reason you’re not just using the standard, asynchronous system APIs – NSURLRequest, NSURLConnection, NSURLDownload, etc?

    @try/@catch are by definition used for exception handling, and should be used as necessary. If you skimp on them your code may fail in unnecessarily interesting ways (e.g. leaving locks dangling) or to unnecessarily degrees (e.g. crashing completely instead of simply failing a specific operation). What you shouldn’t do is use them for flow control – unlike other languages, Objective-C exceptions are for programmer errors, “impossible” conditions, and other such events. Unfortunately a lot of existing Objective-C code is not exception-safe, so while you should utilise them you shouldn’t rely on them.

    They’re not particularly expensive in any of the runtimes you’re likely to use these days – the @try is very cheap, almost free. Only if an exception is thrown is there any significant work done, and since you should only be seeing them in very bad situations – i.e. not frequently – the performance cost is irrelevant.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I would like to run a str_replace or preg_replace which looks for certain words
I have an autohotkey script which looks up a word in a bilingual dictionary
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have an array which has BIG numbers and small numbers in it. I

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.