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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:45:43+00:00 2026-05-27T15:45:43+00:00

I’m not exactly sure how to ask this, or if it’s been asked before…

  • 0

I’m not exactly sure how to ask this, or if it’s been asked before…

So here we go:

I’m trying to write a game in Objective-C for iOS. One main feature of this game is the ability to morph the 2D landscape (technically 3D, however it starts out as a flat, 2D plain with points scattered throughout it to make a perfect mesh of 20 1×1 squares) to the user’s liking; however, in Objective-C, apparently you cannot pass C-Typed arrays through methods.

e.g:

-(VertexS *) getVertexArrayData {
    VertexS myArray[definedAmount]; //VertexS being a structure
    for (int i = 0; i != definedAmount; i++) {
        myArray[i] = vertexData;
    }
    return *myArray;
}

//In the other file (the one with all my rendering), under a different class, inside a method
//Lets pretend the aforementioned method was under a class called "Terrain"
-(id) initWithFrame:(CGRect)frame
{
     terrain = [[[Terrain alloc] init] autorelease];
     [terrain constructLand];
     VertexS *_vertexData = [terrain getVertexArrayData];
     ... etc.
}

Apparently, it doesn’t work. Not saying that that is exactly what I’m doing, but very similar. What happens in my exact code is I use an ivar to hold the vertex/index data after it gets info from the other method.

Considering OpenGL (ES) requires either a vector container (well, in C++), or a C type Array (which is technically the same thing) in order to correctly create an IBO/VBO, I’m at a loss. I’ve been fiddling with it for almost a day and a half now, unable to get around the problem, and too (mentally) fat to learn NSMutableArrays–unless suggested by you, the wonderful community, in which I will pseudo-miraculously lose enough weight to learn NSMutableArrays (probably better said as “I will stop avoiding the unfamiliar solution,”).

I can’t actually remember my other question… Mreh. It probably isn’t relavent but if I remember I will find a way to ask it.

Anyways, any help is requested. I don’t know what else I can possibly do to get around this road block in my project.

  • 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-05-27T15:45:44+00:00Added an answer on May 27, 2026 at 3:45 pm

    Objective-C is a superset of the C language, so anything you can do in plain C will also work in Objective-C. The myArray array is declared on the stack in -getVertexArrayData. It gets abandoned when the method returns and that memory is available for reuse by the next function call. To fix this, allocate the array on the heap using malloc() (or one of its relatives).

    -(VertexS *) getVertexArrayData {
        VertexS *myArray = malloc(definedAmount * sizeof(VertexS));
        for (int i = 0; i < definedAmount; i++) {
            myArray[i] = vertexData;
        }
        return myArray;
    }
    

    C-style memory management doesn’t use reference counting, so don’t forget to free the array when you’re done with it:

    free(_vertexData);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need a function that will clean a strings' special characters. I do NOT

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.