objective-ciphonexcodeprimitive-types

Why do I get "Invalid receiver type 'NSInteger'"?


Probably a simple question: Why do I get an compiler warning for the following objective-C code?

//_classificationView.tag is a NSString

CGFloat imageWidth =  [_classificationView.tag floatValue] * 14.0;

And why does it say something about NSInteger?


Solution

  • Because the tag property is a NSInteger and not a class type. Just use the following instead:

    CGFloat imageWidth =  _classificationView.tag * 14.0;