• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Tracking Multiple Touches For Appropriate Label
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tracking Multiple Touches For Appropriate Label


  • Subject: Re: Tracking Multiple Touches For Appropriate Label
  • From: mmalc Crawford <email@hidden>
  • Date: Mon, 07 Dec 2009 17:09:23 -0800

On Dec 7, 2009, at 4:12 pm, Chunk 1978 wrote:

> 	if ([[[event allTouches] anyObject] view] == self)
> 		{
> 		for (UITouch *touch in touches)
> 			{
> 			CGPoint touchPoint = [[touches anyObject] locationInView:self];
> 			switch ([touches count])
> 				{
> 				case 1:	[self Touch1:touchPoint];
> 						break;
>
This logic doesn't make sense at all.
Moreover the custom method doesn't follow any standard Cocoa naming conventions.

You probably want something more like:


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    NSMutableArray *myTouches = [[NSMutableArray alloc] initWithCapacity:5];
    NSArray *myLabels = [[NSArray alloc] initWithObjects:touchLabel1, touchLabel2, touchLabel3, touchLabel4, touchLabel5, nil];

    UITouch *touch;

    for (touch in touches) {
        if (touch.view == self) {
            [myTouches addObject:touch];
        }
    }

    NSUInteger i, count;
    count = [myTouches count];

    for (i = 0; i < 5; i++) {
        UILabel *label = [myLabels objectAtIndex:i];
        NSString *text = @"";
        if (i < count) {
            UITouch *touch = [myTouches objectAtIndex:i];
            text = NSStringFromCGPoint([touch locationInView:self]);
        }
        label.text = text;
    }

    [myTouches release];
    [myLabels release];
}

(First pass, there may be a better strategy, but at least this will work.)

mmalc

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Tracking Multiple Touches For Appropriate Label
      • From: Chunk 1978 <email@hidden>
References: 
 >Tracking Multiple Touches For Appropriate Label (From: Chunk 1978 <email@hidden>)

  • Prev by Date: NSScroller position
  • Next by Date: Re: NSScroller position
  • Previous by thread: Tracking Multiple Touches For Appropriate Label
  • Next by thread: Re: Tracking Multiple Touches For Appropriate Label
  • Index(es):
    • Date
    • Thread