Cocoa structs and NSMutableArray
Posted
by Circle
on Stack Overflow
See other posts from Stack Overflow
or by Circle
Published on 2010-06-01T02:32:40Z
Indexed on
2010/06/01
2:43 UTC
Read the original article
Hit count: 834
I have an NSMutableArray that I'm trying to store and access some structs. How do I do this? 'addObject' gives me an error saying "Incompatible type for argument 1 of addObject". Here is an example ('in' is a NSFileHandle, 'array' is the NSMutableArray):
//Write points
for(int i=0; i<5; i++) {
struct Point p;
buff = [in readDataOfLength:1];
[buff getBytes:&(p.x) length:sizeof(p.x)];
[array addObject:p];
}
//Read points
for(int i=0; i<5; i++) {
struct Point p = [array objectAtIndex:i];
NSLog(@"%i", p.x);
}
© Stack Overflow or respective owner