I am trying to touch and move objects inside a nsarray as so. I can’t figure out what to do next. Here is the code to show what I’m trying to do (Obviously doesn’t work, but gives an idea). Perhaps someone can guide me.
cardKeys = [[NSArray alloc] initWithObjects:
@"a",
@"b",
@"c",
@"d",
nil];
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
{
UITouch *myTouch = [touches anyObject];
startPoint = [myTouch locationInView:self.view];
[cardKeys:startPoint.x:startPoint.y];
}
}
Your code is poorly formatted. Ex. extraneous pair of curly braces in the method, incorrect indentation. You should consider reading a good book on Objective-C and iOS development, like Programming iOS 5.
Onto your question. I have no idea how you display the NSStrings in that array, why it’s global and not a property/ivar, etc. but one way to make something draggable is to make it a UIView subclass, implement touchesBegan and touchesMoved (as you have), grab the point the user touched in your coordinate system, compare it to the point the person’s finger is when it moves, then offset your position based on that.