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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:53:37+00:00 2026-06-15T16:53:37+00:00

I have some UIButtons that get moved around to different locations, predetermined by an

  • 0

I have some UIButtons that get moved around to different locations, predetermined by an array called totalSmallButtonLocations. So I go through availableLocations, an NSMutableArray, assigning different CGPoints, and removing those points from the availableLocations. Once that is done there is a UIView animation to move the buttons to there new locations.

Currently this works, but as you can see below it is very long, (and in the actual project there are many more buttons and locations):

int randomNumber;
NSValue *val;
CGPoint a, b, c;
NSMutableArray *availableLocations;
availableLocations = [NSMutableArray arrayWithArray:totalSmallButtonLocations];

randomNumber = arc4random_uniform(3);
val = [availableLocations objectAtIndex:randomNumber];
a = [val CGPointValue];
[availableLocations removeObjectAtIndex:randomNumber];
randomNumber = arc4random_uniform(13);
val = [availableLocations objectAtIndex:randomNumber];
b = [val CGPointValue];
[availableLocations removeObjectAtIndex:randomNumber];
randomNumber = arc4random_uniform(12);
val = [availableLocations objectAtIndex:randomNumber];
c = [val CGPointValue];

[UIView animateWithDuration:0.5 animations:^{
    button1.center = a;
    button2.center = b;
    button3.center = c;

So I’m trying to create a loop, but the CGPoint aspect is causing some problems. I think my loop is ok, but I don’t know how to assign it during the animation section, and it is throwing up the error:

“Assigning to ‘CGPoint’ (aka ‘struct CGPoint’) from incompatible type id”:

int randomNumber;
NSValue *val;
CGPoint a;
NSMutableArray *availableLocations;
availableLocations = [NSMutableArray arrayWithArray:totalSmallButtonLocations];
NSMutableArray *points = [NSMutableArray array];

for(int looper = 14; looper > 0; looper--)
{
    randomNumber = arc4random_uniform(looper);
    val = [availableLocations objectAtIndex:randomNumber];
    a = [val CGPointValue];
    [points addObject:[ NSValue valueWithCGPoint:a]];
}
[UIView animateWithDuration:0.5 animations:^{
    button1.center = [points objectAtIndex:1];
    button2.center = [points objectAtIndex:2];
    button3.center = [points objectAtIndex:3];
  • 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-15T16:53:38+00:00Added an answer on June 15, 2026 at 4:53 pm

    The problem is you’re getting a pointer to a CGPoint instead of the CGPoint itself. The problem is here [points objectAtIndex:1]; you’re getting an object out instead of the struct CGPoint. You simply need to wrap it like this [[points objectAtIndex:1] CGPointValue]; and the warning should be gone.

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

Sidebar

Related Questions

I have a NIB with a UIView that contains some UILabels, UIButtons etc. and
I have some UIButtons in a custom table view cell that when pressed I
I have some arbitrary pixel data that I want to save as a PNG.
I have some text lines like that : vt_wildshade2^508^508 vt_ailleurs2^1188^1188 ... vt_high2^13652^13652 Is it
I have some code that will change the background color of a specific label
i have some problems with a Query seem IN dosen't work with Group_concat, that
I have an array of UIButtons . What I want to do is with
I have a UIButton that is linked to some code that invokes UIPrintInteractionController to
I have 10 UIButtons and Single UILabel.All these UIButtons have Some Text as a
I have a scrollView where I add some UIButtons and UIActivityIndicators in the main

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.