2011-07-29 43 views
0

我使用levelManager.m下面的代碼來讀取plist的值,但是當我將Archive上傳到iTunes(AppStore)時,出現錯誤。爲什麼?NSAssert未申報的第一次使用爲什麼?

代碼:

- (float)floatForProp:(NSString *)prop { 
NSNumber * retval = (NSNumber *) [_curStage objectForKey:prop]; 
NSAssert (retval != nil, @"Couldn't find prop %@", prop); 
return retval.floatValue; 
} 

錯誤:

NSAssert未申報首次使用

注意:我注意到,Xcode是想,我給NSAssert 3個參數,而不是2

回答

2

您可以使用NSAssert變種之一,你的情況NSAssert1

#define NSAssert1(condition, desc, arg1) 

所以:

#import <Foundation/Foundation.h> 

- (float)floatForProp:(NSString *)prop 
{ 
    NSNumber * retval = (NSNumber *) [_curStage objectForKey:prop]; 
    NSAssert1 (retval != nil, @"Couldn't find prop %@", prop); 
    return retval.floatValue; 
} 

相關的興趣和蘋果的Assertions and Logging Programming Guidepost

0

如果你認爲它給出三個參數,請使用:

NSAssert (retval != nil, [NSString stringWithFormat:@"Couldn't find prop %@", prop]); 
+0

我嘗試過同樣的錯誤,請更換 –

1

NSAssert (retval != nil, ([NSString stringWithFormat:@"Couldn't find prop %@", prop]));