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 8303225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:28:27+00:00 2026-06-08T17:28:27+00:00

I am trying to store CGPoints from UITouches in an Array. From reading other

  • 0

I am trying to store CGPoints from UITouches in an Array. From reading other threads I have realized that using NSValue seems to be the best way to do this.
Currently I have:

NSMutableArray *dotsArray;
NSValue *pointObj;
UITouch *touch = obj;
CGPoint touchPoint = [touch locationInView:self.view];
// Need to store the CGPoints, can't store directly into an array // as it is a C struct           // so we use NSValue
// CGPoint converted to NSValue
CGPoint point = touchPoint;
pointObj = [NSValue valueWithCGPoint:point];
dotsArray = [NSArray arrayWithObjects:pointObj,nil];
// Print to console the objects in the collection
NSLog(@"array content: %@", dotsArray);
NSLog(@"[dotsArray count] = %i",[dotsArray count]);
// Restore from NSValue to C structures
CGPoint pointRestored = [pointObj CGPointValue];

I want to be able to use:

[dotsArray insertObject:pointObj atIndex:0]; 

in place of

dotsArray = [NSArray arrayWithObjects:pointObj,nil]; 

so that I can increment the placing as I recall the method to store multiple points.

From reading I think this has something to do with the ID type required for the ‘insertObject’, but I don’t fully understand it and am unable to find a solution online.

EDIT: When I use

[dotsArray insertObject:pointObj atIndex:0];

then

NSLog(@"array content: %@", dotsArray);

outputs NULL

  • 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-08T17:28:28+00:00Added an answer on June 8, 2026 at 5:28 pm

    Use addObject: method.

    [dotsArray addObject:pointObj];
    

    I think it will be helpful to you.

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

Sidebar

Related Questions

I'm trying to store BitmapData from a MovieClip that is a PNG with transparency.
I'm trying to store an array value so that I can reuse when Sub
I trying to store some settings in NSUserDefaults, but It seems that the app
When I'm trying to store all <a> elements as objects in array (using $('a')
I am trying to store the data from my sql database into an array.
I'm trying to store MediumBlob data in MySQL using java. But I have no
I'm trying to store in a database some GPS data that I get from
I am trying to store information that can be shared from one screen to
I'm trying to store an image into an SQL database without using temporary files.
I'm trying to store the print output from a function of another module imported,

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.