0

私はobjective-cを学習しようとしていますが、この例で警告が発生しました:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])

{
    @autoreleasepool {

        NSMutableDictionary *booklisting = [NSMutableDictionary dictionary];

        int count; // < Am getting 'unused variable' warning here 

        [booklisting setObject:@"Wind in the Willows" forKey:@"100-432112"];
        [booklisting setObject:@"Tale of Two Cities" forKey:@"200-532874"];
        [booklisting setObject:@"Sense and Sensibility" forKey:@"200-546549"];

        [booklisting setObject:@"Shutter Island" forKey:@"104-109834"];


       NSLog(@"Number of books in dictionary = %lu", [booklisting count]);

誰かが理由を知っていますか?..助けていただければ幸いです..ありがとう

4

5 に答える 5

0
int count; // < Am getting 'unused variable' warning here 

変数カウントを宣言しますが、使用されることはありません。したがって、エラーが表示されます

于 2013-06-10T09:36:08.720 に答える
0

この行を入れてください

count =[booklisting count];

NSLog の前に

int count;またはこの行を削除します

count は配列の getter メソッドです。

于 2013-06-10T08:01:54.493 に答える