- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些非常有趣的逻辑,基本上我有这些数据要检查在我显示下一个 View 之前.. 以防万一数据为空我想弹出 View ,如果数据不为空那么我想加载 View 以将其显示到导航堆栈上。
所以在我的 tableView:didSelectRowAtIndexPath: 方法中,当做出选择时,我获取当前选择 ID 号,这样我就可以将我要解析的数据的值限制为仅相关值。
这就是我的方法中的代码。
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
///... This stuff is for context..
//Get the subview ready for use
VSRViewController *vSRViewController = [[VSRViewController alloc] initWithNibName:@"VSRViewController" bundle:nil];
//Sets the back button for the new view that loads (this overrides the usual parentview name with "Back")
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style: UIBarButtonItemStyleBordered target:nil action:nil];
//Pass Title over to subview
vSRViewController.title = @"SubModel";
//Selected cell gives restult to the subview or o the parent view to be displayed.. when the view is pushed or poped
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@",@"MODEL",cell.textLabel.text];
filterArray = [parsedDataArrayOfDictionaries filteredArrayUsingPredicate:predicate];
//Sets restriction string so that when subCacheData is parsed only values mathching modIdString will be parsed
modIdString = [[filterArray valueForKey:@"MODID"] objectAtIndex:0]; //Restricts Mods dataset
//This sets which if statment to enter in parserDidEndDocument
dataSetToParse = @"ModID";
[self startTheParsingProcess:modCacheData];
//tempModArra is the array I get back from the parser that has had the restriction string applied to it
if ([tempModArray count] == 0) {
NSLog(@"POPVIEW"); //testing
//pop this view to the parent view.. organize all the values that have to be sent back with protocols and delegates
}else if ([tempModArray count] != 0){
//Pass the selected object to the new view controller.
[self.navigationController pushViewController:vSRViewController animated:YES];
//Check if modIndexPath is same as selected if not remove accessory tick from the subview
if (![modIndexPath isEqual:indexPath]){
submodIndexPath = nil;
}
[vSRViewController subModelCachedData:modCacheData indexPath:submodIndexPath dataSetToParse:@"ICSum" modelArray:filterArray modIndexPath:indexPath];
//.....
}
}
}
//...
此代码已针对可读性进行了编辑,其中还有很多其他内容..所以有些地方可能是错误的..因为我已经编辑了一些名称..但它应该没问题..
这就是我的解析器委托(delegate)中发生的事情。
- (void)parserDidEndDocument:(NSXMLParser *)parser
{
//.. other stuff up here.
if (dataSetToParse == @"ModID") {
//This applies the
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@",@"ModID",modIdString]; //modIdString restricts results that have been parsed
NSArray *filteredArray = [parsedDataArrayOfDictionaries filteredArrayUsingPredicate:predicate];
tempModArray = filteredArray;
//what do I do here to get tempModArray back up to tableView:didSelectRowAtIndexPath: method.. this is where I am abit lost.
}
}
就是这样.. 一切正常,唯一的问题是我无法将我的 temoModArray 返回到 tableView:didSelectRowAtIndexPath: 所以我需要一些帮助来思考解决方案。
同样出于上下文考虑,我这样做的原因是,如果 tempModArray 中没有值,我想将用户发送回父 View ,这样他们在转到 subview 进行选择时就不会看到空 TableView ..希望这一切都有意义..我期待着我们的回复。
最佳答案
what do I do here to get tempModArray back up to tableView:didSelectRowAtIndexPath: method
简短的回答:你不知道。
didSelectRow 已经完成了他的工作,即通知应用程序用户选择了该行。现在应用程序有一些工作要做。也就是说,弄清楚它是否会推送一个带有数据的新 View Controller 。所以不要push,判断有没有数据,然后pop;相反,如果没有数据,请不要一开始就推送。
当你的解析器知道它是否有数据时,你有很多选择。我假设您的解析器委托(delegate)不在您的 TableView Controller 类中。您可以:
imo 协议(protocol)方法是最干净的(松散耦合但命名良好),但每个都是自己的。
关于iphone - TableView :didSelectRowAtIndexPath: call to current-view Parser delegates,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9012484/
我想解析一些文本,其中某些字段在大多数情况下都具有结构,但偶尔(由于特殊大小写、拼写错误等)该结构会丢失。 例如常规情况是 Cost: 5,但偶尔会显示 Cost: 5m 或 Cost: 3 + 1
以下有什么区别: parser.setFeature("http://xml.org/sax/features/validation",true); and parser.setFeature("ht
我尝试在 Windows 8.1 上的 Git Bash 客户端中执行 npm install,但收到以下错误: npm WARN optional SKIPPING OPTIONAL DEPENDE
试图理解 evancz/url-parser 模块时,我偶然发现了这种我难以理解的类型声明:( source ) type Parser a b = Parser (State a -> List
我长期使用下面的 TypeScript 和 Vue 预设。它有效,但我还没有理解每个选项,现在要理解它。第一:parser之间有什么区别?和 @typescript-eslint/parser ? p
我正在尝试使用node-sql-parser在nodejs中解析sql查询。 const {Parser} = require('node-sql-parser'); const parser = n
自定义指令中的 ngModelCtrl.$parsers.unshift 和 ngModelCtrl.$parsers.push 之间的确切区别是什么。 当发生对模型生效但对表单本身无效的事情时,我想
我正在寻找 SAX 和 Pull Parser 之间的主要区别。我知道 SAX 解析器非常适合处理大型 XML 文件,因为它不存储 XML 并且只在一个方向上遍历。与 DOM 相比。但我无法找到 SA
我已经按照存档中的说明成功(?)安装了 QJson 库。但是编译器给我这个错误: Undefined reference to QJSon::Parser::Parser(). 我找到了安装库文件的位
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
尝试实现 Cucumber 来进行一些自动化测试。当我使用 junit 运行测试时,出现以下错误 项目路径: src/test/java/ cucumberJava -cucumberjava,ja
我已经阅读了我能找到的所有文档,但是我找不到关于这两个中间件的作用的简单解释。 body-parser 中的body 指的是什么?为什么需要解析正文? Cookie 也类似。我是否更正了 cookie
我在gradle项目中使用Xerces jar,然后在gradle插件中使用该项目的jar:实际上,我正在开发一个gradle插件,其中包含使用gradle项目jar的某些功能的自定义任务;当我尝试运
我正在尝试连接到 Linux 上的 FTP 服务器,当我执行 ftp.listFiles(remote); 时遇到异常 SYST 215 Linux Exception in thread "AW
我有react-app的示例安装,我得到了以下内容 Error: Failed to load parser '@typescript-eslint/parser' declared in '.esl
我在 there 中提到过类似的问题.我正在使用 mvn clean compile site 命令,我的版本是: cobertura.version: 2.5.1 findbugs.version:
我正在 Eclipse 中开发 GWT 应用程序并使用 jdom2 读取一些自定义 xml 属性文件。 在最近的更新之后,我的应用程序现在在尝试读取 xml 文件时失败并出现上述错误。相关堆栈跟踪是:
我正在使用 spring+maven。我正在 tomcat 服务器中部署我的应用程序。当我尝试运行我的应用程序时,突然出现以下错误。 INFO: Starting Servlet Engine: Ap
我在玩dateutil module在 Python 2.7.3 中。我只是想使用: import dateutil dateutil.parser.parse("01-02-2013") 但我得到了
一.入参解析库 argparse 有时候写Python脚本,需要处理入参[-h][-v][-F]...等情况,如果自己来解析的话,会花费很多时间,而且也容易出问题,好在Python有现成的li
我是一名优秀的程序员,十分优秀!