> On Oct 18, 2010, at 4:22 PM, Trygve Inda wrote:
> 
>> How does it derive the plural for he method name countOfWeapons from the
>> class name Weapon?
> 
> It doesn’t. The property name is “weapons” in this case, the same name it
> would have had if it had been an NSArray. The only difference is that instead
> of two methods named -weapons and -setWeapons:, you have a few other methods
> with “Weapons” in their names. The only change is capitalizing the first
> letter to allow for CamelCase.
> 
> Charles

So is "weapons" only defined in IB under the Array binding's model key path?

// Combatant.h:

#import <Foundation/Foundation.h>

@class Weapon;

@interface Combatant : NSObject {
    NSString *name;
    Weapon *weapon1;
    Weapon *weapon2;
    Weapon *weapon3;
    Weapon *selectedWeapon;
    int shieldRating;
}

- (unsigned int)countOfWeapons;
- (id)objectInWeaponsAtIndex:(unsigned int)index;
- (NSString *)name;
- (void)setName:(NSString *)newName;
- (Weapon *)weapon1;
- (void)setWeapon1:(Weapon *)newWeapon1;
- (Weapon *)weapon2;
- (void)setWeapon2:(Weapon *)newWeapon2;
- (Weapon *)weapon3;
- (void)setWeapon3:(Weapon *)newWeapon3;
- (Weapon *)selectedWeapon;
- (void)setSelectedWeapon:(Weapon *)aSelectedWeapon;


// Weapon.h

#import <Foundation/Foundation.h>

@interface Weapon : NSObject
{
    NSString *name;
    int damage;
}

- initWithName:(NSString *)newName damage:(int)newDamage;
- (NSString *)name;
- (void)setName:(NSString *)newName;
- (int)damage;
- (void)setDamage:(int)newDamage;



_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to