2012-01-19 3 views
0

NSIntegerを返している間に警告があります。私はUITableViewのinbuiltメソッドnumberOfRowsInSectionを使用しています。私はそれを返すとき、結果の型 'NSInteger *'(別名 'int *')を持つ関数から 'NSInteger'(別名 'int')を返すポインタの会話と互換性のない整数です)を警告します。NSIntegerを返している間に警告を受けました

私はこのコードを使用しています。

-(NSInteger *)tableView: (UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
NSInteger row=10; 
return row; 
} 

答えて

7

コンパイラの権利を!メソッドはNSIntegerへのポインタを返します。これは、あなたが欲しい署名です:

- (NSInteger)tableView:(UITableView *)table // << 'NSInteger', not 'NSInteger *' 
numberOfRowsInSection:(NSInteger)section 
{ 
… 

NSIntegerは、それがintまたはlongだ、にObjCオブジェクトではありません。

+0

@Justinが... ..多くの時間を保存したので、私は書くべき - (NSInteger *)のtableView:(のUITableView *)のtableView numberOfRowsInSection:(NSInteger *)セクション {} ?? – Akash

+0

@Akash no - 私は更新し、私の答えを明らかにしました。私の答えに見られる署名を使用してください。 – justin

+0

@ジャスティン....あなたにも高尚...ありがとうございます。 – Akash

4

この方法はNSInteger、ないNSInteger *(NSIntegerへのポインタ)を返す必要があり

あなただけの戻り値の型修正する必要があり

-(NSInteger)tableView: (UITableView *)tableView numberOfRowsInSection:(NSInteger)section {...}

+0

@Firoze ...ありがとうバディ...あなたは – Akash

-1

あなたは直接配列にこの

-(NSInteger *)tableView: (UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return 10; 
} 

OR

ストアのような値を返すと、その配列のカウントを返すことができます。

関連する問題