2012-02-19 69 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

相關問題