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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:22:45+00:00 2026-05-27T02:22:45+00:00

new to the Objective-C/iOS scene. Experienced in PHP and C++. I’m having a little

  • 0

new to the Objective-C/iOS scene. Experienced in PHP and C++.

I’m having a little trouble using NSInvocationOperation. Here’s my situation:

With some help online, I’ve a class, getData.h where getData.m contains:

#import "getData.h"

@implementation getData

@synthesize allData;

-(void)loadData{
NSOperationQueue *queue = [NSOperationQueue new];
    NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self                                                                         selector:@selector(getXML) object:nil];

[queue addOperation:operation];
[operation release];
}


-(void)getXML{
NSURL *url = [NSURL URLWithString:@"http://tubeupdates.com/rss/all.xml"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection connectionWithRequest:request delegate:self];

NSError *requestError;
NSURLResponse *urlResponse = nil;
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError];
if (response == nil) {
    // Check for problems
    if (requestError != nil) {
        NSLog(@"Error!");
        }
    }  
}

-(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
if (allData)
    [allData appendData:data];
else 
    allData = [[NSMutableData alloc] initWithData:data];
}


-(void) connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *fullName = [NSString stringWithFormat:@"feed.xml"];
NSString *fullFilePath = [NSString stringWithFormat:@"%@/%@",docDir,fullName];
[allData writeToFile:fullFilePath atomically:YES];
}

-(void)dealloc{
[allData release];
[super dealloc];
}

@end

I know that the method is being called into the queue as I had made a temporary “printthis” method for it to call which simply displayed some text with NSLog. However my issue arises when trying to call the getXML function (to copy the XML file from the server). getXML works if I call it directly, but doesn’t when I add it to the Queue. It’s very likely that I’m missing the bigger picture and that I haven’t fully understood everything before I’ve started. I would appreciate some help on this. It seems no matter how good you are at C++, PHP etc, iOS Programming is a tough one!

  • 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-27T02:22:46+00:00Added an answer on May 27, 2026 at 2:22 am

    In getXML you are doing a synchronous request, meaning that when the method returns, the entire data for the the request will be in your response NSData variable. Instead of waiting for the connection to finish loading with the delegate method, the sendSynchronousRequest blocks and returns when the request is finished. Likewise your didReceiveData delegate method will never get called.

    So to solve your problem, simply take your completion logic that is in the connectionDidFinishLoading method currently, and move it to the getXML method after the synchronous call returns.

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

Sidebar

Related Questions

Still new to Objective C, and I'm having some trouble that I just can't
I'm new to iOS and Objective C and I'm having trouble figuring out how
I am fairly new to Objective-C and iOS programming, and I am having lots
I am new to Objective C. having spent couple of months in iOS, I
I'm new to Objective C (iOS) and I'm having a hard time figuring out
fairly new to Objective-C and iOS development (coming from PHP) and I have a
New to iOS/Objective-C here. I've spent a lot of time trying to figure this
I am new to Objective C and iPhone development. I am using CoreData on
I am new to Objective C and IOS programming so please be patient with
I am fairly new to Objective C and iOS programming but am constantly trying

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.