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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:46:18+00:00 2026-06-07T05:46:18+00:00

So I have this service class that utilize Restkit to consume REST web services.

  • 0

So I have this service class that utilize Restkit to consume REST web services. It is frequently used in my app. Instead of initialize it every time before using it, I create an object of this class and init it in appDelegate. But is this the best way to do so?

I thought about using singleton, but was a bit concerned about it in multi-threading environment. Any suggestions will be really appreciated. Thanks!

EDIT: I should mention that I work in ARC environment.

  • 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-07T05:46:19+00:00Added an answer on June 7, 2026 at 5:46 am

    ARC doesn’t really matter. So long as you understand the negative aspects of singletons and are prepared to have that or deal with it, the pattern works fine.

    What I suggest as an alternative is to design a static class and use the Provider pattern. This is a typical interface I use with RESTKit (this one accesses the facebook graph API).

    @interface FBProvider : NSObject
    
    + (BOOL) canMakeRequests;
    + (id) login;
    + (id) logout;
    
    + (BOOL) application: (UIApplication*) application 
                 openURL: (NSURL*) url 
       sourceApplication: (NSString*) sourceApplication 
              annotation: (id) annotation;
    
    + (id) perform: (RKRequestMethod) method friends: (Friend*) frien;
    + (id) perform: (RKRequestMethod) method boasts: (id) obj;
    + (id) perform: (RKRequestMethod) method invites: (id)obj;
    + (id) perform: (RKRequestMethod) method likes: (id)obj;
    
    @end
    

    There is no singleton, everything is static and if you design your interface to operate from your app data model and NOT your web service UI updates happen automatically.

    Alternatively, if you feel you must use a singleton why not utilize your app delegate which is a true singleton. To expand, I am suggesting your web service or data provider becomes a member of an existing singleton and you will never have to worry about threading issues yourself because hopefully these are handled by Cocoa.

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

Sidebar

Related Questions

I have a web service class that the rest of the framework depends on
I have this code that describes a service: public class navigation_web extends Service {
I currently have service classes that look something like this public class UserService :
I have this web service : using System.Web.Services; namespace Contracts { [WebService(Namespace = http://tempuri.org/)]
I have a Jersey REST service with a resource class that calls methods on
I have a web service class that successfully pulls my JSON from a feed
I have two entities like this: public class Service { public virtual int ServiceId
I have a Windows service built upon ATL 7's CAtlServiceModuleT class. This service serves
I have this error appearing in my web service and even though I'v had
Okey, this is my problem. I have one service class where Ive managed to

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.