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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:04:45+00:00 2026-06-10T14:04:45+00:00

I have a singleton that I’m using to parse XML and then cache it.

  • 0

I have a singleton that I’m using to parse XML and then cache it. The parsing/caching is done with a block. Is there any way for me to pass an argument to this block from another class so that I can change the URL from outside the singleton?

Here’s the code I have now:

// The singleton
+ (FeedStore *)sharedStore
{
    static FeedStore *feedStore = nil;
    if(!feedStore)
        feedStore = [[FeedStore alloc] init];

    return feedStore;
}

- (RSSChannel *)fetchRSSFeedWithCompletion:(void (^)(RSSChannel *obj, NSError *err))block
{
    NSURL *url = [NSURL URLWithString:@"http://www.test.com/test.xml"];

    ...

    return cachedChannel;
}

And here’s the class where I need to modify the NSURL from:

- (void)fetchEntries
{
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

    // Initiate the request...

    channel = [[BNRFeedStore sharedStore] fetchRSSFeedWithCompletion:
           ^(RSSChannel *obj, NSError *err) {
        ...
    }
}

How do I pass an argument from fetchEntries to fetchRSSFeedWithCompletion?

  • 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-10T14:04:46+00:00Added an answer on June 10, 2026 at 2:04 pm

    You would want to add a parameter in the method, not the block.

    Also, when using a completion block, there really is no reason to return anything in the method.

    I’d change it to look like this:

    -(void)fetchRSSFeed:(NSURL *)rssURL completion:(void (^)(RSSChannel *obj, NSError *error))block{
        RSSChannel *cachedChannel = nil;
        NSError *error = nil;
    
        // Do the xml work that either gets you a RSSChannel or an error
    
        // run the completion block at the end rather than returning anything
        completion(cachedChannel, error);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that is a singleton. This singleton is instantiated using GCD
I have developed a small iPhone application by using singleton that I use to
I have a singleton class that I am using as part of a CAPTCHA
Suppose I have singleton class that acts as a data cache. Multiple threads will
I know that singleton classes are inherently not thread-safe. But is there any way
I have a Singleton that is accessed in my class via a static property
I have a singleton object that use another object (not singleton), to require some
I have seen some people in SO commenting that Singleton Pattern is an anti-pattern.
I have a View that is hooked to a ViewModel. I have a singleton
I have a texture manager that I am running as singleton, and wish 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.