Answer the question
In order to leave comments, you need to log in
Why can't I set a new value for an int variable?
All the best!
I'm quite new to Objective-c and C languages in general. Coding only in javascript. Ran into an int
problem .
I have a property
In the implementation code itself, I try to assign the length of the array to it:
but x-code swears :( The following options also do not work:@property (assign,nonatomic) int counter;
_counter = [_myArray count];
_counter = [NSNumber numberWithInteger:[_myArray count]];
_counter = [ intValue];
Answer the question
In order to leave comments, you need to log in
How does he swear? Copy the error.
if
_counter = [[_myArray count] intValue];
then bad receiver type nsuinteger aka int
Because intValue is a method that the simple type nsuinteger does not have.
Treated in 2 ways
1. Knowing the type:
2. Do not use obsolete int, but use NSInteger, in your particular example NSUInteger
UPD. Personal opinion: if you are just starting, then start with swift. There is more information on it now and it is more relevant.
I'm quite new to Objective-c and C languages in general. Coding only in javascript
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question