小编Gol*_*les的帖子

多个iPhone模拟器实例?

是否可以同时运行多个iPhone模拟器应用程序?我希望能够这样做,因为我正在使用一些网络应用程序,每次我想测试的东西都非常痛苦......这对我来说可能是一个巨大的节省时间.

谢谢

iphone ios-simulator

5
推荐指数
1
解决办法
1602
查看次数

在采取行动之前如何知道几个块是否已完成执行?

我使用的animateWithDuration:animations:completion:移动我的用户界面(约4元),之前的几个元素removeFromSuperview:被调用.

我的问题是,我怎么知道在打电话之前所有这些动画都已完成removeFromSuperview:

iphone uiview ios objective-c-blocks ios5

5
推荐指数
1
解决办法
897
查看次数

为什么Uncrustify在我的Objective-C块关闭括号之前强制占用空间?

我遇到了我的问题 - Uncrustify配置问题.我正在使用Xcode自动运行Uncrustify.

出于某种原因,Uncrustify似乎在块声明的关闭Brace之前添加了一个Space.

样本输入

 [_collectionView performBatchUpdates:nil completion:^(BOOL finished) {
 }];
Run Code Online (Sandbox Code Playgroud)

样品输出(注意forced关闭前的空格)

 [_collectionView performBatchUpdates:nil completion:^(BOOL finished) {
  }];
Run Code Online (Sandbox Code Playgroud)

期望的输出

 [_collectionView performBatchUpdates:nil completion:^(BOOL finished) {
 }];
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

objective-c indentation uncrustify xcode5

5
推荐指数
1
解决办法
656
查看次数

声明函数对象进行比较?

我见过其他人的问题,但没有发现适用于我在这里尝试实现的目标。

我正在尝试使用 std::sort 和一个通过我的 EntityManager 类对实体进行排序 std::vector<Entity *>

/*Entity.h*/
class Entity
{
public:
 float x,y;
};

struct compareByX{
 bool operator()(const GameEntity &a, const GameEntity &b)
 {
  return (a.x < b.x);
 }
};   
   
/*Class EntityManager that uses  Entitiy*/

typedef std::vector<Entity *> ENTITY_VECTOR; //Entity reference vector
   
class EntityManager: public Entity
{
private:
 ENTITY_VECTOR managedEntities;

public:
 void sortEntitiesX();
};

void EntityManager::sortEntitiesX()
{
 
 /*perform sorting of the entitiesList by their X value*/
 compareByX comparer;
 
 std::sort(entityList.begin(), entityList.end(), comparer);
}
Run Code Online (Sandbox Code Playgroud)

我收到了十几个错误,比如

: error: no match for …
Run Code Online (Sandbox Code Playgroud)

c++ operators function-object operator-keyword

4
推荐指数
1
解决办法
2万
查看次数

整合Lua在我的游戏引擎中构建我的GameEntities?

我真的想将Lua Scripting添加到我的游戏引擎中.我正在使用Lua并使用luabind将其绑定到C++,但我需要帮助来设计使用Lua构建我的游戏实体的方式.

发动机信息:

面向组件,基本上每个都是在增量T间隔中更新GameEntity的列表components.基本上Game Scenes由游戏实体的集合组成.

所以,这就是困境:

假设我有这个Lua文件来定义GameEntity及其组件:

GameEntity = 
{
 -- Entity Name
 "ZombieFighter",

 -- All the components that make the entity.
 Components = 
 {
  -- Component to define the health of the entity
  health = 
  {
   "compHealth",  -- Component In-Engine Name
   100,    -- total health
   0.1,    -- regeneration rate
  },

  -- Component to define the Animations of the entity
  compAnimation =
  {
   "compAnimatedSprite",

   spritesheet = 
   {
    "spritesheet.gif", -- Spritesheet file name.
    80,     -- …
Run Code Online (Sandbox Code Playgroud)

c++ lua components game-engine

4
推荐指数
1
解决办法
3608
查看次数

有几个C++类需要使用相同的静态方法和不同的实现

我需要几个C++类来使用静态方法"register",但是寄存器的实现在这些类之间有所不同.

它应该是静态的,因为我的想法是用Lua"注册"所有这些类(当然只有一次).

显然我不能用静态纯虚函数声明一个接口.你们有什么建议我做的?简单是受欢迎的,但我认为某种模板可以工作.

我希望实现的例子

class registerInterface
{
public:
    static virtual void register() = 0; //obviously illegal
};

class someClass: public registerInterface
{
    static virtual void register()
    {
        //I register myself with Lua
    }
}

class someOtherClass: public registerInterface
{
    static virtual void register()
    {
        //I register myself with Lua in a different way

    }
}

int main()
{
    someClass::register();
    someOtherClass::register();

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ design-patterns

4
推荐指数
1
解决办法
382
查看次数

为什么静态NSString泄漏?

我有以下代码来检索我的iOS应用程序上的文件路径:

static const NSString * fullPathFromRelativePath(NSString *relPath)
{
    // do not convert a path starting with '/'
    if(([relPath length] > 0) && ([relPath characterAtIndex:0] == '/'))
        return relPath;

    NSMutableArray *imagePathComponents = [NSMutableArray arrayWithArray:[relPath pathComponents]];

    NSString *file = [imagePathComponents lastObject];    
    [imagePathComponents removeLastObject];

    NSString *imageDirectory = [NSString pathWithComponents:imagePathComponents];

    NSString *fullpath = [[NSBundle mainBundle] pathForResource:file
                                                         ofType:NULL
                                                    inDirectory:imageDirectory];
    if (!fullpath)
        fullpath = relPath;

    return fullpath;    
}

static const char * fullCPathFromRelativePath(const char *cPath)
{
    NSString *relPath = [NSString stringWithCString:cPath encoding:NSUTF8StringEncoding];
    const  NSString *path = …
Run Code Online (Sandbox Code Playgroud)

iphone memory-leaks objective-c ios

4
推荐指数
1
解决办法
5973
查看次数

从URL获取XML文件到NSData对象?

我需要将一个.xml文件从URL地址加载到NSData对象中,以便使用我已经拥有的一些库进行进一步解析(但是他们问我.xml文件是NSData),我该怎么做?

url格式是这样的:

http://127.0.0.1/config.xml

iphone cocoa-touch objective-c nsdata

3
推荐指数
1
解决办法
1万
查看次数

混合Lua和PHP?

我真的想混合使用Lua和PHP,例如接收PHP查询并使用Lua脚本处理查询的某些部分(从获得初始查询的PHP脚本调用).

关于这个的任何线索?我已经看到一些库使用Lua作为某种PHP替换,但我没有看到如何同时使用Lua和PHP.

谢谢

php lua

3
推荐指数
2
解决办法
5199
查看次数

使用numpy获取子矩阵

我正在尝试使用numpy(python newbie here)

创建rigth维度的归零矩阵

num_rows = 80
num_cols = 23
A = numpy.zeros(shape=(num_rows, num_cols))
Run Code Online (Sandbox Code Playgroud)

在矩阵上操作

k = 5
numpy.transpose(A)
U,s,V = linalg.svd(A)
Run Code Online (Sandbox Code Playgroud)

提取子矩阵

 sk = s[0:(k-1), 0:(k-1)]
Run Code Online (Sandbox Code Playgroud)

结果出错

Traceback (most recent call last):
File "tdm2svd.py", line 40, in <module>
sk = s[0:(k-1), 0:(k-1)]
IndexError: too many indices
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

python numpy

3
推荐指数
1
解决办法
1万
查看次数