Hi, I'm trying to make an object in one array equal to another. If I set each property individually, it works fine, but I want to set one object equal to antoher without writing a function to run through each property.
-(void)DrawCard: (int) wp{
[self GetNc :(wp)];
if (nc > 0){
((card*) [[Hands objectAtIndex:wp] objectAtIndex:nc]) = ((card*) [[Draws objectAtIndex:wp] objectAtIndex:0])
}
}
(wp stands for which player. All GetNc does it set the integer nc (for new card), by finding the highest index of a card object currently being used in Hands).
That won't compile, but setting an individual property does:
((card*) [[Hands objectAtIndex:wp] objectAtIndex:nc]).suit = ((card*) [[Draws objectAtIndex:wp] objectAtIndex:0]).suit;
And trying without casting gives invalid l-value error as well ie:
[[Hands objectAtIndex:wp] objectAtIndex:nc] = [[Draws objectAtIndex:wp] objectAtIndex:0];
(Is it ever possible to set an array object without casting?)
I appreciate your time to read and respond. Cheers!