Bad Receiver type 'NSInteger' (aka 'int')

icodes picture icodes · Sep 22, 2012 · Viewed 11.2k times · Source
int thumbCount = [_totalThumbs thumbsViewNumberOfThumbs:self];
  1. _totalThumbs is a NSInteger type property.
  2. thumbsViewNumberOfThumbs is a method of type NSInteger.

I need to get the count in 'int' itself so that i can use it for further calculations. Any suggestions?

Answer

user529758 picture user529758 · Sep 22, 2012

This question doesn't quite make sense.

First of all, NSInteger is not a class. It's a typedef for long long. That means, you can't use it as an Objective-C message receiver.

What you possibly want is that call this thumbsViewNumberOfThumbs: method on the object whose class implements it and assign that to an NSInteger. Or assign it to an int directly - for such a simple case, int and NSInteger are compatible types (assuming you don't want to work with such big numbers who don't fit into an int...)