Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listenfor ... OBJECTS? #50

Closed
traviskirton opened this issue May 2, 2012 · 1 comment
Closed

listenfor ... OBJECTS? #50

traviskirton opened this issue May 2, 2012 · 1 comment

Comments

@traviskirton
Copy link
Collaborator

is it possible to include a method for listening to multiple objects at the same time?

example:

listenFor:@"something" fromObjects:(NSArray *)anArrayOfObjects andRunMethod: ...

Might be handy...

@traviskirton
Copy link
Collaborator Author

Added

-(void)listenFor:(NSString *)notification fromObjects:(NSArray *)objectArray andRunMethod:(NSString *)methodName;

and

-(void)stopListeningFor:(NSString *)methodName objects:(NSArray *)objectArray;

The following code works:

#import "C4WorkSpace.h"

@implementation C4WorkSpace {
    C4Shape *r1, *r2, *r3;
}

-(void)setup {

    CGPoint p;

    r1 = [C4Shape rect:CGRectMake(0, 0, 50, 50)];
    p = self.canvas.center; p.x -= 100;
    r1.center = p;
    [self.canvas addShape:r1];

    r2 = [C4Shape rect:CGRectMake(0, 0, 50, 50)];
    p = self.canvas.center;
    r2.center = p;
    [self.canvas addShape:r2];

    r3 = [C4Shape rect:CGRectMake(0, 0, 50, 50)];
    p = self.canvas.center; p.x += 100;
    r3.center = p;
    [self.canvas addShape:r3];

    [self listenFor:@"touchesBegan" fromObjects:[NSArray arrayWithObjects:r1,r3, nil] andRunMethod:@"test"];
}

-(void)test {
    C4Log(@"test");
}

@end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant