views:

251

answers:

1

I've looked through countless questions on here and elsewhere and cannot for the life of me figure out what I'm doing wrong.

I'm trying to store an array of CGPoints as NSValues inside of an NSMutableArray named points like so on the iPhone:

NSValue *point = [NSValue valueWithCGPoint:firstTouch];
NSLog(@"NSValue *point = %@", point);
[points addObject:point];

NSLOG OUTPUT
NSValue *point = NSPoint: {120, 221}

Everything is going smooth converting from the CGPoint to NSValue. But when I try to retrieve the point I get nothing.

NSValue *getPoint = [points objectAtIndex:0];
CGPoint thePoint = [getPoint CGPointValue];
NSLog(@"Point = %@", NSStringFromCGPoint(thePoint));

NSLOG OUTPUT
Point = {0, 0}

The points should be the same but I'm getting a null result.

For testing purposes this is happening in the touchesBegan method.

Does anyone have any idea where I'm going wrong? Thanks in advance.

+1  A: 

I never allocated my array into memory and initialized it. My points weren't being stored into an array because there was no array that existed.

Matt Dice
man if i had a dollar for every time this has happened to me...
Dave DeLong