Take the 2-minute tour ×

I am using NSURLConnection to fetch data from an RSS Feed.I have set default time out value to 30 seconds.In Low wifi connectivity situations i get a timeout response(From did fail with error) as normal after 30 seconds.I make sure the connection is released when Callback comes.But after another 30 seconds(60seconds in total after request is sent) i get another Callback.I have tried to debug but the 2nd callback is not tracked any where.

Also this appears for the very first time when i send the request.Next time when i send the request only one call back appears. There is another thread with the same issue but i have not found any concrete answer there.I will really appreciate if someone can help me out.

Here is my connection creation,delegate,FailwithError and Callback Function

- (void)LoadRSSFeed {
if (Stories == nil) {
    [activityIndicator startAnimating];
    rssParser = [[Parser alloc] init];
    [rssParser parseRssFeed:@"http://twitter.com/statuses/user_timeline/56202272.rss" withDelegate:self];
} else {
    [newsTable reloadData];


//Parser Class where connection is called
- (void)parseRssFeed:(NSString *)url withDelegate:(id)aDelegate {
[self setDelegate:aDelegate];
responseData = [[NSMutableData data] retain];
NSURL *baseURL = [[NSURL URLWithString:url] retain];

NSLog(@"Creating Connection");
NSURLRequest *request = [NSURLRequest requestWithURL:baseURL      cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];

if (_delegate)
    [_delegate receivedItems:nil];


//Delegate Callback Function in MainClass.m
- (void)receivedItems:(NSArray *)theItems {

[rssParser setDelegate:nil];//setting delegates to nil
[rssParser release];
rssParser = nil;

Stories = theItems;
if([activityIndicator isAnimating]){
        if([Stories count])
            [newsTable reloadData];
        NSLog(@"Showing Alert");
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Time Out"  delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil, nil];
        [alert show];
        [alert release];
[activityIndicator stopAnimating];

The alert View in callback function is being called twice.Once after normal 30 second timeout and one after 60 seconds which i am unable to track.Even if i add Breakpoints or NSlogs before the Alert view they are not called or captures.

Any help here would really be appreciated .


share|improve this question
Are you absolutely sure that you're only sending one request? –  Morten Fast Jul 18 '11 at 7:11
add comment

1 Answer

The documentation for –[NSURLConnectionDelegate connection:didFailWithError:] states the following:

Once the delegate receives this message, it will receive no further messages for connection.

Since the alert view is shown in your Parser's delegate implementation, you might be calling receivedItems: from other places than your Parser object. In fact, since break points and log statements are ignored, you could even have some other code that shows the timeout alert (maybe a timer or something?) rather than a Parser delegate callback.

share|improve this answer
add comment

Your Answer


