0
我有這樣的代碼來配置核心數據的單元: 代碼:核心數據文本網址爲RSS iPhone應用程序
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = [[managedObject valueForKey:@"data"] description];
}
但是當我點擊該行,在這裏,我想要做的是: 代碼:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here -- for example, create and push another view controller.
RssFunViewController *rssFun = [[RssFunViewController alloc] initWithNibName:@"RssFunViewController" bundle:nil];
//NSManagedObject *selectedObject = [[self fetchedResultsController] objectAtIndexPath:indexPath];
[self.navigationController pushViewController:rssFun animated:YES];
[rssFun release];
}
插入一行文本到這個網址: 代碼:
-(BOOL)fetchAndParseRss{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
//To suppress the leak in NSXMLParser
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
NSURL *url = [NSURL URLWithString:@"http://news.search.yahoo.com/rss?ei=UTF-8&p=lindsay+lohan&fr=news-us-ss"];
BOOL success = NO;
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[parser setDelegate:self];
[parser setShouldProcessNamespaces:YES];
[parser setShouldReportNamespacePrefixes:YES];
[parser setShouldResolveExternalEntities:NO];
success = [parser parse];
[parser release];
[pool drain];
return success;
}
因此,在說lindsay + lohan的地方,我會把用戶搜索詞放在這裏。問題是,第三部分代碼是在BlogRss.m中,前兩部分是在RootViewController.m中?不知道如何建立鏈接?任何想法...
感謝
嗨馬庫斯,感謝這個詳細的回答,肯定是有用的,但我的應用程序的事情是,在URL中的代碼,駐留在BlogRssParser.m其中依次填充RssFunViewController視圖。所以我需要在RootViewController和BlogRssParser之間建立一個鏈接?所以BlogRssParser可以填充RssFunViewController的tableview ......這是有道理的? – benhowdle89 2010-11-11 12:32:08
沒關係。答案依然如此。您需要將對管理對象的引用從知道它的控制器傳遞給不知道它的控制器(或對象)。 – 2010-11-11 13:20:01
明白了!謝謝! – benhowdle89 2010-11-11 14:12:25