osx - How To Compare Integer to Objective-C enum -
osx - How To Compare Integer to Objective-C enum -
- (void)updatecheckboxes { nsarray *availablefuncunits = _scanner.availablefunctionalunittypes; for(int = 0; < [availablefuncunits count]; i++) { } }
if set breakpoint within loop, elements of nsarray * 'availablefuncunits' (__nscfnumber *)(int)0 , (__nscfnumber *)(long)3.
the array supposed contain elements of next :
enum { icscannerfunctionalunittypeflatbed = 0, icscannerfunctionalunittypepositivetransparency = 1, icscannerfunctionalunittypenegativetransparency = 2, icscannerfunctionalunittypedocumentfeeder = 3 }; typedef nsuinteger icscannerfunctionalunittype; shouldn't able following?
if([availablefuncunits objectatindex:i] == icscannerfunctionalunittype.icscannerfunctionalunittypedocumentfeeder) {} but gives me error saying 'expected identifier or '('.
how can perform comparing correctly? lot help!
there 2 problems see: 1) array availablefuncunits contains nsnumber objects. cant straight compare them primitive types (nsuinteger).
so if should this:
icscannerfunctionalunittype type = [availablefuncunits[i] integervalue] if(type == icscannerfunctionalunittypedocumentfeeder){} in snippet comparing pointer, not object.
2) error seeing because proper way utilize enums is:
i = icscannerfunctionalunittypedocumentfeeder objective-c osx cocoa enums
Comments
Post a Comment