2010-11-18 12 views

Antwort

1

Ich denke, dass Sie den Download erneut anfordern müssen. Sie wollen wahrscheinlich eine neue Methode LazyTableAppDelegate hinzuzufügen, das dies tut, denn das ist die Klasse ist, die die erste Download tut:

- (void)reloadAppList 
{ 
    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:TopPaidAppsFeed]]; 
    self.appListFeedConnection = [[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self] autorelease]; 
} 

auch ändern - [LazyTableAppDelegate handleLoadedApps:] die alten Daten zu löschen, wie dieser :

- (void)handleLoadedApps:(NSArray *)loadedApps 
{ 
    [self.appRecords removeAllObjects]; 
    rootViewController.entries = [NSArray array]; 
    [self.appRecords addObjectsFromArray:loadedApps]; 

    // tell our table view to reload its data, now that parsing has completed 
    [rootViewController.tableView reloadData]; 
} 

Ich habe das selbst nicht versucht, aber das ist die Grundidee.

+0

Hallo Ryan, danke für die Antwort. Ich habe das versucht und ich verstehe, dass dies die Hauptidee ist, aber es stürzt ab, und das Ändern von handleLoadedApps zum Löschen der Objekte verhindert, dass der RSS-Feed anfänglich geladen wird. Jede weitere Anleitung würde sehr geschätzt werden. – Hanson

+0

Das Ändern von 'rootViewController.entries = [NSArray array];' to '[rootViewController.imageDownloadsInProgress removeAllObjects]; in' handleLoadedApps' scheint für mich zu funktionieren. In meinem Fall erstelle ich eine neue 'NSURLConnection' in' ApplicationWillEnterForeground' – MrDatabase

1

(kann nicht einen Weg finden, um einen Kommentar ...)

Ich bin hier das gleiche Problem haben und versucht, diesen Ansatz. Habe die appRecords mit removeAllObjects gelöscht, aber beim zweiten Mal funktioniert alles für die Artikel, aber die Icons werden nicht geladen.

Sie können das Problem reproduzieren, indem die ursprüngliche Beispielcode auf diese Weise zu ändern:

- (void)applicationDidFinishLaunching:(UIApplication *)application 

{ // konfigurieren und zeigen das Fenster [Fenster addSubview: [self.navigationController Ansicht]]; [Fenster makeKeyAndVisible];

// Initialize the array of app records and pass a reference to that list to our root view controller 
self.appRecords = [NSMutableArray array]; 
rootViewController.entries = self.appRecords; 

// NSURLRequest * urlRequest = [NSURLRequest requestWithURL: [NSURL URLWithString: TopPaidAppsFeed]]; //self.appListFeedConnection = [[[NSURLConnection-Zuordnung] initWithRequest: urlRequest-Delegat: self] autorelease];

// Test the validity of the connection object. The most likely reason for the connection object 
// to be nil is a malformed URL, which is a programmatic error easily detected during development 
// If the URL is more dynamic, then you should implement a more flexible validation technique, and 
// be able to both recover from errors and communicate problems to the user in an unobtrusive manner. 
// 
//NSAssert(self.appListFeedConnection != nil, @"Failure to create URL connection."); 

// show in the status bar that network activity is starting 
// [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 
[self reloadData]; 

}

  • (IBAction) Reload: (id) sender { [self reload]; }

- (void) {reload NSLog (@ "Aktualisieren von Einträgen"); [self.appRecords removeAllObjects]; // [[myTableViewController imageDownloadsInProgress] removeAllObjects];

NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:TopPaidAppsFeed]]; 
self.appListFeedConnection = [[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self] autorelease]; 

// Test the validity of the connection object. The most likely reason for the connection object 
// to be nil is a malformed URL, which is a programmatic error easily detected during development 
// If the URL is more dynamic, then you should implement a more flexible validation technique, and 
// be able to both recover from errors and communicate problems to the user in an unobtrusive manner. 
// 
NSAssert(self.appListFeedConnection != nil, @"Failure to create URL connection."); 

// show in the status bar that network activity is starting 
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 

}