Thread: Request for member 'center' in something not a union or a structure error? Objective

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    Request for member 'center' in something not a union or a structure error? Objective

    So Im 12 and Im new to Objective c. I am creating an app, and in one part of the app I have to lower troops down from the top of the screen to the bottom. my code for doing this is as follows:


    -(void)lowerParatroopers {

    for (int x=1; x<=[array count]; x++) {
    [array objectAtIndex:x].center=[array objectAtIndex:x].center-1;
    }
    I have an array called "array" and Every second a new trooper at a random location at the top is appearing, which I add to my array. So I am doing a for loop from 1 to the number of items in the array, and in between the for loop I am getting the next object(a UIImageView of the trooper that randomly gets generated) and lowering it by one pixel, but under the

    rray objectAtIndex:x].center=[array objectAtIndex:x].center-1;

    I get two errors saying that

    Request for member 'center' in something not a union or a structure


    Please help me. I think the problem is that I have to create an @property(nonatomic,retain) and a synthesize for each item created. If thats the case, How would I do that in a (void) in the implementation file? Thanks a bunch!

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Objective C isn't C. But if it were, your problem would be here:[code][array objectAtIndex:x].center[/quote]What is this supposed to be? If it were C, it would be more like:
    Code:
    type arrayname[ arraysize ];
    
    arrayname[ objectAtIndex:x ].center = foo;
    This forum isn't really for Objective C. It's for real (Standard) C.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 02-04-2011, 10:07 AM
  2. Replies: 2
    Last Post: 11-10-2010, 05:04 PM
  3. Replies: 1
    Last Post: 05-18-2010, 04:14 AM
  4. Problem Passing Structure Reference To Function
    By soj0mq3 in forum C Programming
    Replies: 9
    Last Post: 04-24-2010, 10:27 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

Tags for this Thread