我正在開發一個應用程序,該應用程序可以在tableview中顯示來自多個網站的提要,用戶可以在其中添加其他提要。使用ASIHTTPRequest添加新提要後獲取重複提要
我使用ASIHTTPRequest根據以下tutorial創建了應用程序。
所以,我的問題是,我添加一個新的鏈接後,刷新方法我從所有來源重複的帖子。
這裏是我的viewDidLoad方法:
- (void)viewDidLoad
{
[super viewDidLoad];
self.title [email protected]"Lajmet";
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
self.allEntries = [NSMutableArray array];
self.queue = [[NSOperationQueue alloc] init];
self.feeds = [NSMutableArray arrayWithObjects:@"http://pcworld.al/feed",@"http://geek.com/feed", @"http://feeds.feedburner.com/Mobilecrunch",@"http://zeri.info/rss/rss-5.xml",
nil];
[self.tableView reloadData];
[self refresh];
}
刷新方法如下:
-(void)refresh
{
for (NSString *feed in _feeds)
{
NSURL *url = [NSURL URLWithString:feed];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[_queue addOperation:request];
}
}
在此screenshot,你可以看到應用程序的樣子以及如何添加屏幕適用於新來源。我配置完成按鈕,以便它自動添加一個饋送來測試它是否工作。
-(void)addSourcesViewController:(AddSourcesViewController *)controller didAddSource:(RSSEntry *)source
{
Source *newSource = [[Source alloc] init];
newSource.name = @"Test";
newSource.link = @"http://lajmeshqip.com/feed";
[self.feeds addObject:newSource.link];
NSLog(@"%@", self.feeds);
[self dismissViewControllerAnimated:YES completion:nil];
[self refresh];
}
所以我的問題是,點擊完成按鈕後,所有條目都重複,它們顯示在tableview中。我嘗試在最後一種方法中使用[self.tableView reloadData];
而不是[self refresh];
,但是新鏈接根本沒有出現。
有沒有辦法使用ASIHTTPRequest或我可以遵循的任何提示加載最後一個條目?我是新人,不知道要採取哪種方法。任何幫助將不勝感激。
非常感謝!
Granit
如果您添加ASIHTTP的DelegateMethod以瞭解您對下載的數據所做的工作,將會非常有用。 –