Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
代码可以在模拟器上工作,但不能在iPhone上工作?_Iphone_Ios_Cocoa Touch - Fatal编程技术网

代码可以在模拟器上工作,但不能在iPhone上工作?

代码可以在模拟器上工作,但不能在iPhone上工作?,iphone,ios,cocoa-touch,Iphone,Ios,Cocoa Touch,我被这个问题难住了:我已经在iPhone模拟器4.3和5.0中测试了我的应用程序的过滤功能,一切正常,但在iPhone上,谓词得到了错误的结果。(我怀疑这与正则表达式有关,但我没有发现错误。) if(!selectionDidChange) 返回; [比赛发布]; NSPredicate*谓词=[NSPredicate谓词WithFormat:@“类元[c]]@”, 通用关键字]; NSPredicate*regional=[NSPredicate predicateWithFormat:@“r

我被这个问题难住了:我已经在iPhone模拟器4.3和5.0中测试了我的应用程序的过滤功能,一切正常,但在iPhone上,谓词得到了错误的结果。(我怀疑这与正则表达式有关,但我没有发现错误。)

if(!selectionDidChange)
返回;
[比赛发布];
NSPredicate*谓词=[NSPredicate谓词WithFormat:@“类元[c]]@”,
通用关键字];
NSPredicate*regional=[NSPredicate predicateWithFormat:@“regional==NIL或regional==NO或”
@“(地区==是和标题。%K!=无)”,当前语言];
NSPredicate*exclusive=(exclusiveUpgrade?[NSPredicate谓词WithValue:是]:
[NSPredicate PREDITEWITHFORMAT:@“独占==NIL或独占==NO”];
NSMutableArray*谓词=[[[NSMutableArray alloc]initWithCapacity:5]自动释放];
对于(int i=0;i=0)
A_添加(谓词,([NSPredicate predicateWithFormat:@“元匹配[c]]@),
S(S(@“*\\b”,D(A(A(关键字,i),@“值”),选择),@“名称”),@“\\b.*))));
}
NSPredicate*复合=[NSCompoundPredicate和PredicateWithSubPredicates:谓词];
[谓词移除所有对象];
[谓词addObject:谓词];
[谓词addObject:component];
谓词=[NSCompoundPredicate and PredicateWithSubpredicates:A_NEW(区域、独占、,
[NSCompoundPredicate或PredicateWithSubPredicates:谓词];
matches=[[entries filteredArrayUsingPredicate:predicate]retain];
selectionDidChange=否;
如需澄清:

  • 条目
    关键字
    是字典数组,尽管
    关键字
    稍微复杂一些。重要的是,
    entries
    中的每个字典都包含一个名为
    meta
    的字符串,该字符串可以是这样的:“a,B,C,D”。如果用户搜索“C”,正则表达式应该匹配。还有其他一些条件似乎不是问题所在,因为我检查了编译后的谓词,它看起来很好
  • 我应该提到,谓词的第一部分(
    meta-LIKE[c]]@
    )也给出了iPhone上的预期结果
  • 我这里有一些常用的方便宏:
    A\u ADD=addObject:
    D=objectForKey:
    A=objectAtIndex:
    A\u NEW=arraywhithobjects:
    L=count
    S=stringByAppendingString:
    。(是的,我很懒:D)

我在这里忽略了什么?

以下是其他人遇到类似问题时的要点:

  • iPhone上的
    nspreditate
    与iOS模拟器上的相应实现之间没有功能差异
  • 如果你的应用程序在实际设备上的行为与在模拟器上的不同,请仔细检查文件名和其他字符串的大小写,如jmstone所说
  • 如果问题依然存在,请从模拟器和设备中删除应用程序。Xcode有许多自动行为,但它不会清理模拟器或设备上的任何东西

  • 模拟器中的某些项目不区分大小写。i、 e.“@2x”和“@2x”都会在模拟器中显示视网膜图像,但不会在设备中显示。确保你传递的大写字母是你期望的。谢谢你的提示,很高兴知道。然而,我仔细查看了NSLog输出,发现我设备上的应用程序从过时的缓存文件中提取数据;我应该先删除应用程序,谓词就可以正常工作了。有时候很容易…很高兴你能做到。提供答案或将此小狗标记为关闭:)
    if (!selectionDidChange)
        return;
    [matches release];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"meta LIKE[c] %@",
                              UniversalKeyword];
    NSPredicate *regional = [NSPredicate predicateWithFormat:@"regional == NIL OR regional == NO OR "
                             @"(regional == YES AND title.%K != NIL)", CurrentLanguage];
    NSPredicate *exclusive = (exclusiveUpgrade ? [NSPredicate predicateWithValue:YES] :
                              [NSPredicate predicateWithFormat:@"exclusive == NIL OR exclusive == NO"]);
    NSMutableArray *predicates = [[[NSMutableArray alloc] initWithCapacity:5] autorelease];
    for (int i = 0; i < L(keywords); i++)
    {
        int selection = [D(A(keywords, i), @"selection") intValue];
        if (selection >= 0)
            A_ADD(predicates, ([NSPredicate predicateWithFormat:@"meta MATCHES[c] %@",
                                S(S(@".*\\b", D(A(D(A(keywords, i), @"values"), selection), @"name")), @"\\b.*")]));
    }
    NSPredicate *compound = [NSCompoundPredicate andPredicateWithSubpredicates:predicates];
    [predicates removeAllObjects];
    [predicates addObject:predicate];
    [predicates addObject:compound];
    predicate = [NSCompoundPredicate andPredicateWithSubpredicates:A_NEW(regional, exclusive,
                [NSCompoundPredicate orPredicateWithSubpredicates:predicates])];
    matches = [[entries filteredArrayUsingPredicate:predicate] retain];
    selectionDidChange = NO;