cgpoint

How do I add a CGPoint to NSMutableArray?

I want to store my CGPoint to the NSMultable Array, so , I have method like this: [self.points addObject:CGPointMake(x, y)]; But I got the error, it said that : Incompatible type for argument 1 of "addObject". So, I check out the API, (void)addObject:(id)anObject anObject The object to add to the end of the receiver...

NSKeyedArchiver and NSValue - How to Archive?

How do I archive an array of NSValues ? What conversions should I make to do this? It won't archive it as is. Code: [[NSUserDefaults standardUserDefaults] setObject:[NSKeyedArchiver archivedDataWithRootObject:[[NSArray alloc] initWithArray:drawingsArray]] forKey:@"NSValuesArray"]; Error: *** Terminating app due to uncaught exce...

moving CGPoint a certain distance along a certain heading...iphone

this seems like such a simple problem but I have been unable to find an answer (and im no good at math). I am trying to move a UIView to a new CGPoint X distance away along a certain heading. What is the formula for determining the new coordinates? (i do no want this to be animated, just an instantaneous move) something like: x = 100;...

Using CGPoints in an NSArray

I have been trying to create an array stating the location of a UIImageView in an app I've been working on. What I am trying to do is by using an array I can store the location of my "player" image by using its x,y and z coordinates. The script I am trying to accomplish would look like NSArray *location[3]; -(IBAction)startup;{ [locat...

Converting 'x' value of a CGPoint ivar to NSTimeInterval?

Hi I have a velocity ivar defined as a CGPoint. I need to somehow extract just the 'x' value of velocity, and then use this to call-send a message to the following method signature -(void) adjustTimer:(NSTimeInterval*)newInterval How do I obtain just the 'x' value of a CGPoint? Do I then need to convert or cast this result before ca...

Problems with CGPoint/touches event

I'm having some problems with storing variables from my touch events. The warning I get when I run this is that coord and icoord are unused, but I used them in the viewDidLoad implementation, is there a reason why this does not work? Any suggestions? #import "iGameViewController.h" @implementation iGameViewController @synthesize pla...

Problems with converting a CGPoint to a string.

I have been having problems with converting a CGPoint to a string. I have tried various methods, but this seems like the most promising but it still won't work. Any suggestions? Here is my code: -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; coord = [touch lo...

finding location of specific characters in UILabel on iPhone

I have a UILabel with some text, say "Hello World abcdefg" The label can have multiple lines, different font sizes etc. Question: How do I find the coordinates of all letters "d" in this UILabel. Logical first step is find the position of those characters in the string (UILabel.text), but then how do I translate that into coordinates w...

Invalid initializer, CGPoint

i have this code and on the second line it gives me an error that says invalid initialzer this is the code: -(void)setPlayerPosition:(CGPoint)position { CGPoint tileCoord = [self tileCoordForPosition:position]; int tileGid = [_meta tileGIDAt:tileCoord]; if (tileGid) { NSDictionary *properties = [_tileMap propertiesForGID:tileGid]; ...

Finding closest object to CGPoint

I have four UIViews on a UIScrollView (screen divided into quartiles) On the quartiles, I have a few objects (UIImageViews), on each quartile. When the user taps the screen, I want to find the closest object to the given CGPoint? Any ideas? I have the CGPoint and frame (CGRect) of the objects within each quartile. UPDATE: Red Pins...

Memory management about CGPoint

refer to http://stackoverflow.com/questions/1746378/cgpointmake-explaination-needed Correct me if I am wrong, in the implementation of CGPointMake, CGPoint p; declare a local variable of a struct, which should should be freed after leaving the scope. But why the function can return the value without risk? Anyway, assume that implementa...

How to save NSMutableArray of NSValue in CoreData?

I'm doing drawing app for ipad which need to save multiples of NSMutableArray of CGPoint (Converting into NSValue), suggest me for choosing coredata functions or any other approachs for saving more number of arrays ...