On Jul 2, 2009, at 4:41 AM, Agha Khan wrote:

I am adding a object (somedata)
        for (int i = 0; i < 7; i++)
        {
                SomeData* singleNutData = [[SomeData alloc] init];
                [NutArray addObject: SomeData];
        }

I am getting warning.
NSArray may not respond to -addObject.
(Message without a matching method signature will be assumed to return id and accept '...' as arguments.)

Am I am doing something wrong?
I am new to Apple development and how can I get rid of this message.

Thanks in advance.
Best regards
-Agha

NSArray is a class representing array objects that *cannot* be changed, once they're created and initialized. You're trying to change one by adding a new object to the array, and the compiler is telling you that NSArray objects do not respond to the message that adds an object. Makes sense, no?

What you need is to declare your array as an instance of NSMutableArray, which is the class that represents arrays which you *can* change.

You should read the documentation for both NSArray and NSMutableArray to better understand the differences between the two (for instance, what messages NSMutableArray responds to which NSArray doesn't).

Wagner

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to