PeterK
PeterK

Reputation: 4301

sending messages to objects

I am trying to send a message with multiple objects but just cannot get it to work. It works perfectly using one message (objectsArray) but not both.

PlayerData.h:

- (void)savePlayerData:(NSArray *)objectsArray andKey:(NSString *)keyString;

PlayerData.m:

- (void)savePlayerData:(NSArray *)objectsArray andkey:(NSString *)keyString {

The following is where i try to call PlayerData from another .m:

    NSString *keyString = [[NSString alloc] init];  
    keyString = @"key test";
    PlayerData *accessPlayerDataFunction = [PlayerData new];
    [accessPlayerDataFunction savePlayerData:objs andKey:keyString];

objs is the NSArray.

The error i get is:

warning: incomplete implementation of class 'PlayerData' warning: method definition for '-savePlayerData:andKey:' not found

Upvotes: 0

Views: 91

Answers (1)

Thomas Zoechling
Thomas Zoechling

Reputation: 34243

The problem is that you have a typo in your selector name within the implementation (the ".m" file).

in the header you write andKey (camel case)

(void)savePlayerData:(NSArray *)objectsArray andKey:(NSString *)keyString;

and in the implementation you have andkey (no camel case)

(void)savePlayerData:(NSArray *)objectsArray andkey:(NSString *)keyString

Apart from that you leak memory:

NSString *keyString = [[NSString alloc] init];
keyString = @"key test";

By assigning @"key test" to your variable, you loose reference to the original object you allocated the line before. You can just assign @"key test" to keyString.

Upvotes: 4

Related Questions