2014-02-18 3 views
0

Я занимаюсь написанием модульных тестов для моего проекта. Ниже приводится тестовый модуль:Ошибка BAD ACCESS при настройке свойства с помощью модульного теста

-(void)testRecordMapControl 
{ 
    MKPinAnnotationView *tempMap = [[MKPinAnnotationView alloc] init]; 
    NSMutableDictionary *testDict = [mAutomate_MapView recordMapControl:1 :0 :1 :[ @"-1" stringByAppendingFormat:[email protected]"-2"] :tempMap :MAPVIEW]; 
    // STAssertNotNil(testDict, @"not null"); 
} 

И следующий метод испытывается:

+(NSMutableDictionary *) recordMapControl:(int)globalIndex:(int) mapCntlIndex :(int) controlIdIndex :(NSString *) viewIndexInList :(id) control :(NSString *)controlType{ 

    MKPinAnnotationView *mapView = (MKPinAnnotationView*)control; 
    mAutomate_ViewBean *mapBean = [[mAutomate_ViewBean alloc] init]; 


    NSMutableDictionary *tempDict = [mapBean proxyForJsonCreation]; 
    [tempDict setValue:[NSString stringWithFormat:@"%d",[mapView animatesDrop]] ? [NSString stringWithFormat:@"%d",[mapView animatesDrop]]:@"null" forKey:ANIMATESDROP]; 
    [tempDict setValue:[NSString stringWithFormat:@"%d",[mapView pinColor]] ? [NSString stringWithFormat:@"%d",[mapView pinColor]]:@"null" forKey:PINCOLOR]; 

    return tempDict; 


} 

Я получаю BAD ошибка доступа на выполнение следующей строки:

[tempDict setValue:[NSString stringWithFormat:@"%d",[mapView animatesDrop]] ? [NSString stringWithFormat:@"%d",[mapView animatesDrop]]:@"null" forKey:ANIMATESDROP]; 

Пожалуйста, кто-нибудь скажет мне, где я ошибаюсь?

ответ

0

АнимированныеДорог возвращения двойной? Похоже, что он возвращает bool ...

[tempDict setValue:([mapView animatesDrop] ? @"1" : @"null") forKey:ANIMATESDROP]; 
+0

% d - спецификатор формата целочисленный (десятичный) и BOOL - это typedef для integer в Cocoa. Это не проблема. – MrTJ

+0

он возвращает BOOL. Дело в том, что этот метод не представляет никакой проблемы, когда он обычно называется. Проблема возникла, когда я назвал ее из единичного теста. – StudentX

+0

получается, что я получаю БЕСПЛАТНЫЙ ДОСТУП даже после комментирования двух строк после объявления tempDict. Это происходит, когда управление возвращается к тесту. – StudentX

Смежные вопросы