Xcode Confusing NSMutableArray with NSMutableDictionary
I am writing an iOS application, which required me to use some NSMutableArray's. Before, I was using NSMutableDictionary (under the same variable name), but I commented out code that has to do with the dictionary. Now, when using NSMutableArray, I am calling t开发者_开发知识库he method -addObject:. However, Xcode keeps giving me a warning saying that "NSMutableDictionary may not respond to -addObject:". However, I have checked, and checked again, and again, that the definition and allocation both say NSMutableArray not NSMutableDictionary. I even tried commenting out NSMutableDictionary code in my class, however the warning persists. The application runs fine and can execute the methods successfully, however the warnings are annoying. I am using Snow Leopard 10.6.8, Xcode 4.0.2. I tried restarting Xcode, but it didn't help. Any suggestions?
.h:
NSArray *array;
NSMutableArray *mutableArray;
.m
//allocation
mutableArray = [[NSMutableArray alloc] init];
//line where I get warning
[mutableArray addObject:someObj];
This happens with every array I tested with.
I'm not at my workstation at the moment, but try >man xcodeindex, it can clean out the index for you. (if it's still in 10.6)
Enter Xcode's preferences, and find the Locations pane. In it, you have the "Derived Data", containing all sorts of non-primary information about your project. You can navigate to it by clicking the little arrow to the right of the path.
Close all your Xcode projects and quit Xcode. Now, delete the contents of the Derived Data folder, and reopen your project. Xcode should (pretty quickly) regenerate the index.
Okay, here's what happened. There was one version of the .m, and two versions of the .h. The .m was importing the wrong version of the .h-the one I wasn't updating. Therefor, when I updated the .h, it didn't do anything. After I deleted the wrong .h and added the right .h to the project, everything worked fine - the warnings went away and changes in the .h reflected in the .m.
精彩评论