Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7760595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:55:53+00:00 2026-06-01T13:55:53+00:00

When trying to pass a CGPoint to a method the point is passed, but

  • 0

When trying to pass a CGPoint to a method the point is passed, but once inside the called method the CGPoint values show (inf, inf)? So passing the location CGPoint to the createShapeAt method ends in code not working. Maybe I am not implementing something correctly or do I need to COPY the CGPoint when passed over?

- (void)handleTap:(UITapGestureRecognizer *)recognizer {
if ([recognizer isKindOfClass:[UITapGestureRecognizer class]])
{
    NSLog(@"User just tapped!");
    CGPoint location = [recognizer locationInView:recognizer.view];
    float scale = [(BasicCanvasUIView *)recognizer.view scale];
    location = CGPointMake(location.x / scale, location.y / scale);
    [self createShapeAt:location];
}
}

- (void)createShapeAt:(CGPoint)point {
//Create a managed object to store the shape
----------------------------------------------------------------------------
<-- WHEN I GET HERE ON BREAKPOINT THE (point) VARIABLE SHOWS "(inf,inf)"  -->
----------------------------------------------------------------------------
NSManagedObject *shape = nil;

//Randomly choose a Circle or a Polygon
int type = arc4random() % 2;
if (type == 0) { // Circle
    //Create the circle
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Circle" inManagedObjectContext:self.managedObjectContext];
    NSManagedObject *circle = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:self.managedObjectContext];
    shape = circle;

    //Randomly create a radius and set the attributes of the circle
    float radius = 10 + (arc4random() % 90);
    [circle setValue:[NSNumber numberWithFloat:point.x] forKey:@"x"];
    [circle setValue:[NSNumber numberWithFloat:point.y] forKey:@"y"];
    [circle setValue:[NSNumber numberWithFloat:radius] forKey:@"radius"];
} else { // Polygon
    //Create the Polygon
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Polygon" inManagedObjectContext:self.managedObjectContext];
    NSManagedObject *polygon = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:self.managedObjectContext];
    shape = polygon;

    //Get the vertices. At this point, no Vertex objects for this shape exist.
    //Anything you add to the set, however, will be added to the Vertex entity;
    NSMutableSet *vertices =[polygon mutableSetValueForKey:@"vertices"];

    //Create a random number of vertices
    int nVertices = 3 + (arc4random() % 20);
    float angleIncrement = (2 * M_PI) / nVertices;
    int index = 0;
    for (float i = 0; i < nVertices; i++) {
        // Generate random values of each vertex
        float a = i * angleIncrement;
        float radius = 10 + (arc4random() % 90);
        float x = point.x + (radius * cos(a));
        float y = point.y + (radius * sin(a));

        // Create the Vertex managed object
        NSEntityDescription *vertexEntity = [NSEntityDescription entityForName:@"Vertex" inManagedObjectContext:self.managedObjectContext];
        NSManagedObject *vertex = [NSEntityDescription insertNewObjectForEntityForName:[vertexEntity name] inManagedObjectContext:self.managedObjectContext];

        //Set teh values for the vertex
        [vertex setValue:[NSNumber numberWithFloat:x] forKey:@"x"];
        [vertex setValue:[NSNumber numberWithFloat:y] forKey:@"y"];
        [vertex setValue:[NSNumber numberWithFloat:index++] forKey:@"index"];

        //Add the Vertex object to the relationship
        [vertices addObject:vertex];

    }// ----------------- END IF/ELSE (circle and polygon done) -------------------------------------------------------------------------------------

    //Set the shapes color
    [shape setValue:[self makeRandomColor] forKey:@"color"];

    //Add  the same shape to both canvases
    [[topView.canvas mutableSetValueForKey:@"shapes"] addObject:shape];
    [[bottomView.canvas mutableSetValueForKey:@"shapes"] addObject:shape];

    //Save the context
    NSError *error = nil;
    if (![self.managedObjectContext save:&error]) {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }

    // Tell the views to repaint themselves
    [topView setNeedsDisplay];
    [bottomView setNeedsDisplay];

 }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:55:54+00:00Added an answer on June 1, 2026 at 1:55 pm

    One obvious possibility is that recognizer.view.scale is zero. Have you tested that?

    Put this statement in handleTap:, before you call createShapeAt::

    NSLog(@"recognizer.view.scale = %f", scale);
    

    What is the output of that statement? If it’s zero, that’s your problem. You need to use a scale that is not zero.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam trying to pass dynamic argument values i.e username from request using spring ioc.But
I just trying to pass some values but it's throwing an error all the
I'm trying to pass a userId (string) in the URL which will be passed
Im trying to pass multiple things from a webpage inside a UIWebView back to
I am trying to pass not only the dropdownlist ID using this, but I'm
I'm trying to pass two values on Button_Click Event public MyClass() { Int64 po
Trying to pass some values into an imagebutton click event, something like this: <asp:ImageButton
I'm trying to pass one method to another in elisp, and then have that
Trying to pass GetFullNamePDF() to the Filename attribute, but getting the following error: Compile
I am trying to pass the id through reverse. But it's not working. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.