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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:59:41+00:00 2026-06-05T23:59:41+00:00

Im trying to encode into a NSValue an multidimensional array of structs. This is

  • 0

Im trying to encode into a NSValue an multidimensional array of structs.

This is the struct:

typedef struct {
    float Position[3];
    float Color[4];
} Vertex;

const Vertex Vertices[] = {
    // Front
    {{1, -1, 0}, {1, 0, 0, 1}},
    {{1, 1, 0}, {1, 0, 0, 1}},
(etc...)

I need to encode into a NSValue to store it in the object “Block”.

This is what I do to store:

Block *newBlock = [[Block alloc] init];
newBlock.blockVertices = [NSValue value:&Vertices withObjCType:@encode(Vertex)];

And to get it back:

Vertex tempVertices[24];
[newBlock.blockVertices getValue:&tempVertices];

Everything seems to work fine, then I try to compare values like this:

for (int i = 0; i < 24; i++){
    NSLog(@"%f = %f", Vertices[i].Position[0], tempVertices[i].Position[0]);
    NSLog(@"%f = %f", Vertices[i].Position[1], tempVertices[i].Position[1]);
    NSLog(@"%f = %f", Vertices[i].Position[2], tempVertices[i].Position[2]);
    NSLog(@" ");
}

And I’m getting weird results, like:
-1.000000 = -1.998905

where could be the problem? Any help would be appreciated.

  • 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-05T23:59:42+00:00Added an answer on June 5, 2026 at 11:59 pm

    You need to tell @encode how many Vertex structs are being encoded, for example:

    [NSValue value:&Vertices withObjCType:@encode(Vertex[24])];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to encode an array which contains floats and NaN into JSON
I'm trying to encode a Python array into json using simplejson.dumps: In [30]: s1
I'm trying to encode some denotational semantics into Agda based on a program I
I am trying to store a json encoded array into a MySQL field. The
I am trying to encode a JSP servlet into JSON. What's the equivalent in
So I'm trying to simply encode a character into a file but for some
I am trying to convert some xml into a json object using PHP. This
I am having trouble trying to hard encode a text document into my C#
am trying to encode the values given in an Text View into an QR
I am trying to return my SQL query array into a javascript array and

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.