2012-02-19 168 views
1

我正在使用SOCKit库为我的应用实现URL路由器。我有一个自定义的Router类,用于跟踪所有有效路线,并实施match方法,该方法在给定路线NSString的情况下将其与相应的视图控制器相匹配。为了使事情更容易,匹配的视图控制器必须实现Routable协议,该协议需要采用NSDictionary作为参数的initWithState:方法。下面是相关的代码:调试和发布版本之间的不同行为

- (id)match:(NSString *)route 
{ 
    for (NSArray *match in routePatterns) { 
    const SOCPattern * const pattern = [match objectAtIndex:kPatternIndex]; 
    if ([pattern stringMatches:route]) { 
     Class class = [match objectAtIndex:kObjectIndex]; 

     NSLog(@"[pattern parameterDictionaryFromSourceString:route]: %@", [pattern parameterDictionaryFromSourceString:route]); 

     UIViewController<Routable> *vc; 
     vc = [[class alloc] initWithState:[pattern parameterDictionaryFromSourceString:route]]; 
     return vc; 
    } 
    } 
    return nil; 
} 

当我运行与debug配置的应用,[pattern parameterDictionaryFromSourceString:route]产生的期望是什么:

[pattern parameterDictionaryFromSourceString:route]: { 
    uuid = "e9ed6708-5ad5-11e1-91ca-12313810b404"; 
} 

在另一方面,当我运行该应用程序会与release配置, [pattern parameterDictionaryFromSourceString:route]产生一个空字典。我真的不知道如何调试。我检查了自己的代码,看看debugrelease构建之间是否存在任何明显差异,并且也查看了SOCKit source code。想法?谢谢!

+0

对不起,这已经在https://github.com/jverkoey/sockit/commit/8e666d78ad6c888c72aaa00cdbadcd2da6ebf65d中修复了。 – featherless 2012-04-25 18:53:26

+0

谢谢!我很高兴它现在再次运作。 – cbrauchli 2012-04-27 15:50:37

回答

2

我今天刚刚遇到这个问题。在我的情况的问题是,发布版本受阻断言,但在-performSelector:onObject:sourceString:-parameterDictionaryFromSourceString:是这一重要线:

NSAssert([self gatherParameterValues:&values fromString:sourceString], 
    @"The pattern can't be used with this string."); 

,当断言被转换为无操作,消失,博采从未发生过。没有参数值,没有太多的事情发生!我把它改为以下(将问题提交到GitHub库):

if(![self gatherParameterValues:&values fromString:sourceString]) { 
    NSAssert(NO, @"The pattern can't be used with this string."); 
    return nil; 
} 


编辑:报告为 issue #13

+1

这已经修复https://github.com/jverkoey/sockit/commit/8e666d78ad6c888c72aaa00cdbadcd2da6ebf65d – featherless 2012-04-25 18:53:01

+0

啊感谢您找出了!接得好。当我意识到出了什么问题时,我处于紧缩状态,所以我只是黑了一些代码,不使用SOCKit。不过,我现在会回到使用SOCKit! – cbrauchli 2012-04-27 15:50:13

相关问题