You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
418 B
33 lines
418 B
4 years ago
|
#include <stdio.h>
|
||
|
#include <objc/Object.h>
|
||
|
|
||
|
@protocol Job
|
||
|
-do;
|
||
|
@end
|
||
|
|
||
|
@interface MyJob : Object<Job>
|
||
|
-do;
|
||
|
@end
|
||
|
@implementation MyJob
|
||
|
-do
|
||
|
{
|
||
|
printf("Doing Job\n");
|
||
|
return self;
|
||
|
}
|
||
|
@end
|
||
|
|
||
|
@interface JobExecutor : Object
|
||
|
-doWith: (id<Job>)job for: (int)count;
|
||
|
@end
|
||
|
|
||
|
@implementation JobExecutor
|
||
|
-doWith: (id<Job>)job for: (int)count
|
||
|
{
|
||
|
for (int i = 0; i < count; ++i)
|
||
|
{
|
||
|
[job do];
|
||
|
}
|
||
|
return self;
|
||
|
}
|
||
|
@end
|