Chewie The Chorkie
Chewie The Chorkie

Reputation: 5244

Obj C: Pass the name of an object from one class to another from method call

How do you pass the name of an object from one class method to use another class method? Say if the class that calls the other classes method is called class2 and the other is class1.

class2 is not required to know anything about class1's object. So if inside a class2 method something like this was called:

int idNum = [class1 getidNum:@"blockKind1" coord:tileCoord];

class1's method would be able to interpret that object name somehow of one of its own. I know that isn't right, just an example.

Current "class2" interface as requested:

@interface HeroClass : CCLayer {
    DebugZoneLayer * debugZoneLayer;

    CCSprite *_heroSprite;
    CCSpriteBatchNode *_heroSpriteSheet;
    CCAction *_heroSpriteFlyAction;
    NSMutableArray *_collisPushPoints;

    @public int _collisPushPointsNums;

    @public float _travelRectCenterPointX;
    @public float _travelRectCenterPointY;

    NSMutableArray *_travelRectCenterPoints;

    @public float _travelRectSteps;

    /* amount of spacing in px between each center point
     of a rect that checks collision detection */

    @public int _rectCheckRes;

    @public int _speed;

    @public float _heroRectLookAhead;

    @public CGPoint _vel;

    @public CGRect _travelRectForTiles;
}

Upvotes: 0

Views: 158

Answers (1)

Terry Wilcox
Terry Wilcox

Reputation: 9040

Key Value Coding?

a mechanism allowing applications to access the properties of an object indirectly by name (or key), rather than directly through invocation of an accessor method or as instance variables

Upvotes: 1

Related Questions