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

  • SEARCH
  • Home
  • 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 8284753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:13:31+00:00 2026-06-08T11:13:31+00:00

I have a few maps (tilemaps made with Tiled QT) and I would like

  • 0

I have a few maps (tilemaps made with Tiled QT) and I would like to create a CGpoint **array based on the objects groups of those maps (I call them Waypoints).

Each maps can have a few set of waypoints that I call path.

//Create the first dimension
int nbrOfPaths = [[self.tileMap objectGroups] count];
CGPoint **pathArray = malloc(nbrOfPaths * sizeof(CGPoint *));

Then for the second dimension

//Create the second dimension
int pathCounter = 0;
while ((path = [self.tileMap objectGroupNamed:[NSString stringWithFormat:@"Path%d", pathCounter]])) {
    int nbrOfWpts = 0;
    while ((waypoint = [path objectNamed:[NSString stringWithFormat:@"Wpt%d", nbrOfWpts]])) {
        nbrOfWpts++;
    }
    pathArray[pathCounter] = malloc(nbrOfWpts * sizeof(CGPoint)); 
    pathCounter++;
}

Now I want to fill up the pathArray

//Fill the array
pathCounter = 0;
while ((path = [self.tileMap objectGroupNamed:[NSString stringWithFormat:@"Path%d", pathCounter]]))
{
    int waypointCounter = 0;
    //Get all the waypoints from the path
    while ((waypoint = [path objectNamed:[NSString stringWithFormat:@"Wpt%d", waypointCounter]]))
    {
        pathArray[pathCounter][waypointCounter].x = [[waypoint valueForKey:@"x"] intValue];
        pathArray[pathCounter][waypointCounter].y = [[waypoint valueForKey:@"y"] intValue];
        NSLog(@"x : %f & y : %f",pathArray[pathCounter][waypointCounter].x,pathArray[pathCounter][waypointCounter].y);
        waypointCounter++;
    }

    pathCounter++;
}

When I NSLog(@”%@”,pathArray), it shows me the entire pathArray will the x and y.

HOWEVER 2 problems :

  • The y value is never correct (the x value is correct and my tilemap.tmx is correct too)

    <object name="Wpt0" x="-18" y="304"/>  <-- I get x : -18 and y :336 with NSLog
    <object name="Wpt1" x="111" y="304"/>  <-- I get x : 111 and y :336
    <object name="Wpt2" x="112" y="207"/>  <-- I get x : 112 and y :433
    
  • I get a EX_BAD_ACCESS at the end of the NSLog

EDIT
Thank you about the NSLog(%@) concerning CGPoint.
However, I get the y value with this line (in the ugly loop):

NSLog(@"x : %f & y : %f",pathArray[pathCounter][waypointCounter].x,pathArray[pathCounter][waypointCounter].y);
  • 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-08T11:13:33+00:00Added an answer on June 8, 2026 at 11:13 am

    First of all, you can’t NSLog CGPoint like that because it is not an object. %@ expects an objective c object to send a description message to.

    Secondly, you can use an NSValue wrapper and then use NSMutableArray as you would with any other object. Is there a reason you don’t want to do that? You can add arrays inside other arrays as you are doing.

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

Sidebar

Related Questions

I have a few static unordered_maps in my application that I would like to
I have few basic questions on session management in GWTP. Now, we create a
I have few text fields like SSN , phone number and email id. I
I have few question in this regard When you create an internet page, does
We have few components like libraries dlls When initially created I ran the following
I would like to create a zoomable image map containing irregular shapes upon which
I have written a class (AbcdBase) which holds several static objects, these include maps
I have a Google Maps KML feed which stopped working a few days ago.
I have a few maps with certain areas (zones) which I'll want to capture
I have few questions about ssis transction isolation levels. consider a scenario:I have an

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.