0

i used the code below in the levelManager.m to read values from a plist but when I am making an Archive to upload to itunes (AppStore) I get an error. why ?

the code :

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

the error:

NSAssert undeclared first use

Note I notice that xcode is thinking that I am giving NSAssert 3 parameters instead of 2

Bobj-C
  • 5,131
  • 8
  • 45
  • 79

3 Answers3

2

You could use one of the NSAssert variants, in your case NSAssert1:

#define NSAssert1(condition, desc, arg1)

So:

#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;
}

Related post of interest and Apple's Assertions and Logging Programming Guide.

Community
  • 1
  • 1
petert
  • 6,602
  • 3
  • 35
  • 45
1

Replace it with

NSAssert (retval != nil, ([NSString stringWithFormat:@"Couldn't find prop %@", prop]));
Andrea Bergia
  • 5,375
  • 1
  • 24
  • 38
0

If you think its thinking you are giving three parameters, use this:

NSAssert (retval != nil, [NSString stringWithFormat:@"Couldn't find prop %@", prop]);
Bushra Shahid
  • 3,559
  • 1
  • 25
  • 37