2011-06-30 31 views
1

Objective-C,iOS的xCode使整数指针从一个整数没有在单身人士铸造警告int

在一个类,我想分配一个单身整数的值。现在我有:

[ExGlobal sharedMySingleton] .tetraCountEx = tetraCount;

我得到了这个警告之前,并已能够解决它,但是这似乎我不得不做一些不同的东西,让编译器知道tetraCountEx是一个整数。我只是不知道如何。

+0

你可以添加如何在'EXGlobal'中声明'tetraCountEx'? –

+0

是tetraCountEx(nonatomic,assign)? – meggar

回答

1

该错误是试图存储一个数字作为指针的结果。无论您发布任何代码如何tetraCountEX宣布我只能猜测你的问题是什么。

在原因可能是tetraCountEx被定义为NSNumber,如果是这样的话使用

[ExGlobal sharedMySingleton].tetraCountEx = [NSNumber numberWithInt:tetraCount]; 
//or numberWithInteger: or the appropriate type 

另一个原因可能会突然宣布tetraCountEx为指针

//Remove the * if this is the case 
@property(nonatomic, assign) int *tetraCountEx; 
+0

谢谢..这是因为我有一个*的财产! – VagueExplanation