• <i id='vTLq8'><tr id='vTLq8'><dt id='vTLq8'><q id='vTLq8'><span id='vTLq8'><b id='vTLq8'><form id='vTLq8'><ins id='vTLq8'></ins><ul id='vTLq8'></ul><sub id='vTLq8'></sub></form><legend id='vTLq8'></legend><bdo id='vTLq8'><pre id='vTLq8'><center id='vTLq8'></center></pre></bdo></b><th id='vTLq8'></th></span></q></dt></tr></i><div id='vTLq8'><tfoot id='vTLq8'></tfoot><dl id='vTLq8'><fieldset id='vTLq8'></fieldset></dl></div>

    <legend id='vTLq8'><style id='vTLq8'><dir id='vTLq8'><q id='vTLq8'></q></dir></style></legend>

  • <small id='vTLq8'></small><noframes id='vTLq8'>

      <tfoot id='vTLq8'></tfoot>

        • <bdo id='vTLq8'></bdo><ul id='vTLq8'></ul>

        如何从 Objective-C 中的方法返回 C 数组?

        How to return a C-array from method in Objective-C?(如何从 Objective-C 中的方法返回 C 数组?)
        <i id='kf2Yx'><tr id='kf2Yx'><dt id='kf2Yx'><q id='kf2Yx'><span id='kf2Yx'><b id='kf2Yx'><form id='kf2Yx'><ins id='kf2Yx'></ins><ul id='kf2Yx'></ul><sub id='kf2Yx'></sub></form><legend id='kf2Yx'></legend><bdo id='kf2Yx'><pre id='kf2Yx'><center id='kf2Yx'></center></pre></bdo></b><th id='kf2Yx'></th></span></q></dt></tr></i><div id='kf2Yx'><tfoot id='kf2Yx'></tfoot><dl id='kf2Yx'><fieldset id='kf2Yx'></fieldset></dl></div>
          <tbody id='kf2Yx'></tbody>

        • <bdo id='kf2Yx'></bdo><ul id='kf2Yx'></ul>
        • <small id='kf2Yx'></small><noframes id='kf2Yx'>

              1. <tfoot id='kf2Yx'></tfoot><legend id='kf2Yx'><style id='kf2Yx'><dir id='kf2Yx'><q id='kf2Yx'></q></dir></style></legend>
                  本文介绍了如何从 Objective-C 中的方法返回 C 数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个返回变量的函数,我想知道如何返回一个数组,问题是它不是一个 NSArray,它只是一个像这样的普通 C 数组...

                  I have a function that returns a variable and I want to know how to return an array the issue is it isn't an NSArray it is just an average C array like this...

                  -(b2Fixture*) addFixturesToBody:(b2Body*)body forShapeName:(NSString*)shape
                  {
                      BodyDef *so = [shapeObjects objectForKey:shape];
                      assert(so);
                         FixtureDef *fix = so->fixtures;
                      int count = -1;
                      b2Fixture *Fixi[4];
                      while(fix)
                      {
                  
                          count++;
                          NSLog(@"count = %d",count);
                          Fixi[count]= body->CreateFixture(&fix->fixture);
                          if (Fixi[count]!=0) {
                              NSLog(@"Fixi %d is not 0",count);
                          }
                          if (body->CreateFixture(&fix->fixture)!=0) {
                              NSLog(@"body %d is not 0",count);
                          }
                  
                          fix = fix->next;
                  
                      }
                  
                      return *Fixi;
                  
                  }
                  

                  如果你看到一些你不知道的变量类型,那是因为我正在使用 cocos2d 框架制作游戏,但我返回的是 b2Fixture 的变量...此代码编译但只保存第一个块的值数组fixi [0]"不是我想要传递的整个数组

                  If you see some variable types you don't know it's because I'm using cocos2d framework to make a game but I'm returning a variable of b2Fixture... This code compiles however only saves the value of the first block of the array "fixi[0]" not the whole array like I want to pass

                  任何帮助 :) 谢谢你

                  anyhelp :) thankyou

                  推荐答案

                  不能返回本地数组.您需要进行某种动态分配或使用诸如将数组放入结构中的技巧.

                  You can't return a local array. You'll need to do some kind of dynamic allocation or pull a trick like having the array inside a structure.

                  这里有一个链接到一篇深入的文章应该能帮到你.

                  Here is a link to an in-depth article that should help you out.

                  这篇关于如何从 Objective-C 中的方法返回 C 数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                  Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
                  Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                  How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)
                  Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)
                  <i id='DhHIP'><tr id='DhHIP'><dt id='DhHIP'><q id='DhHIP'><span id='DhHIP'><b id='DhHIP'><form id='DhHIP'><ins id='DhHIP'></ins><ul id='DhHIP'></ul><sub id='DhHIP'></sub></form><legend id='DhHIP'></legend><bdo id='DhHIP'><pre id='DhHIP'><center id='DhHIP'></center></pre></bdo></b><th id='DhHIP'></th></span></q></dt></tr></i><div id='DhHIP'><tfoot id='DhHIP'></tfoot><dl id='DhHIP'><fieldset id='DhHIP'></fieldset></dl></div>
                  1. <tfoot id='DhHIP'></tfoot>
                      <tbody id='DhHIP'></tbody>
                  2. <small id='DhHIP'></small><noframes id='DhHIP'>

                    <legend id='DhHIP'><style id='DhHIP'><dir id='DhHIP'><q id='DhHIP'></q></dir></style></legend>

                          • <bdo id='DhHIP'></bdo><ul id='DhHIP'></ul>