Objective c 如何在每次导航时仅更改内容,同时保持用户对象不变
我使用了一个在线教程,该教程使用touchXML并解析了一个特定的网站,因此它为我提供了所有元素及其值Objective c 如何在每次导航时仅更改内容,同时保持用户对象不变,objective-c,ios,nsmutabledictionary,touchxml,uiswipegesturerecognizer,Objective C,Ios,Nsmutabledictionary,Touchxml,Uiswipegesturerecognizer,我使用了一个在线教程,该教程使用touchXML并解析了一个特定的网站,因此它为我提供了所有元素及其值 // Convert the supplied URL string into a usable URL object NSURL *url = [NSURL URLWithString: blogAddress]; // Create a new rssParser object based on the TouchXML "CXMLDocument" class, this i
// Convert the supplied URL string into a usable URL object
NSURL *url = [NSURL URLWithString: blogAddress];
// Create a new rssParser object based on the TouchXML "CXMLDocument" class, this is the
// object that actually grabs and processes the RSS data
CXMLDocument *rssParser = [[[CXMLDocument alloc] initWithContentsOfURL:url options:0 error:nil] autorelease];
// Create a new Array object to be used with the looping of the results from the rssParser
NSArray *resultNodes = NULL;
// Set the resultNodes Array to contain an object for every instance of an node in our RSS feed
resultNodes = [rssParser nodesForXPath:@"//item" error:nil];
// Loop through the resultNodes to access each items actual data
for (CXMLElement *resultElement in resultNodes) {
// Create a temporary MutableDictionary to store the items fields in, which will eventually end up in blogEntries
NSMutableDictionary *blogItem = [[NSMutableDictionary alloc] init];
// Create a counter variable as type "int"
int counter;
// Loop through the children of the current node
for(counter = 0; counter < [resultElement childCount]; counter++) {
// Add each field to the blogItem Dictionary with the node name as key and node value as the value
[blogItem setObject:[[resultElement childAtIndex:counter] stringValue] forKey:[[resultElement childAtIndex:counter] name]];
}
// Add the blogItem to the global blogEntries Array so that the view can access it.
[blogEntries addObject:[blogItem copy]];
//将提供的URL字符串转换为可用的URL对象
NSURL*url=[NSURL URLWithString:blogAddress];
//基于TouchXML“CXMLDocument”类创建一个新的rssParser对象,这是
//对象,该对象实际捕获和处理RSS数据
CXMLDocument*rssParser=[[CXMLDocument alloc]initWithContentsOfURL:url选项:0错误:nil]autorelease];
//创建一个新的数组对象,用于rssParser结果的循环
NSArray*resultNodes=NULL;
//将resultNodes数组设置为包含RSS提要中每个节点实例的对象
resultNodes=[rssParser nodesForXPath:@//item”错误:nil];
//循环遍历resultNodes以访问每个项目的实际数据
对于(resultNodes中的CXMLElement*resultElement){
//创建一个临时的MutableDictionary来存储其中的items字段,它最终将在blogEntries中结束
NSMutableDictionary*blogItem=[[NSMutableDictionary alloc]init];
//创建类型为“int”的计数器变量
整数计数器;
//循环遍历当前节点的子节点
用于(计数器=0;计数器<[resultElement childCount];计数器++){
//将每个字段添加到blogItem字典中,节点名称作为键,节点值作为值
[blogItem setObject:[[resultElement childAtIndex:counter]stringValue]forKey:[[resultElement childAtIndex:counter]名称]];
}
//将blogItem添加到全局blogEntries数组中,以便视图可以访问它。
[blogEntries addObject:[blogItem copy]];
现在,由于我拥有blogEntries mutableDictionary中的所有数据,我在顶部有一个label对象和两个bar按钮项,上面写着back&next
我真正想做的是
1)单击“下一步”,使用相同的标签对象并从blogEntries mutableDictionary加载下一个数据
2)单击“上一步”,使用相同的标签对象并从blogEntries可变字典加载以前的数据
如果有人除了在不使用工具栏按钮项的情况下加载新内容之外还有其他想法,欢迎您
我的项目主要处理rss提要,所以我只想通过单击next或使用swipegesture浏览下一条新闻。谢谢