mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
New file.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@904 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0f0f8eb0cb
commit
bd0385dee1
1 changed files with 44 additions and 0 deletions
44
Testing/invocation.m
Normal file
44
Testing/invocation.m
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* A demonstration of writing and reading with NSArchiver */
|
||||
|
||||
#include <objects/Invocation.h>
|
||||
#include <objects/Array.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
|
||||
@interface NSNumber (printing)
|
||||
- (void) print;
|
||||
@end
|
||||
|
||||
@implementation NSNumber (printing)
|
||||
- (void) print
|
||||
{
|
||||
printf("%d\n", [self intValue]);
|
||||
}
|
||||
@end
|
||||
|
||||
int main()
|
||||
{
|
||||
id obj;
|
||||
id inv;
|
||||
id array;
|
||||
char *n;
|
||||
int i;
|
||||
|
||||
obj = [NSObject new];
|
||||
inv = [[MethodInvocation alloc]
|
||||
initWithTarget: obj selector: @selector(name)];
|
||||
[inv invoke];
|
||||
[inv getReturnValue: &n];
|
||||
printf ("name is %s\n", n);
|
||||
[inv release];
|
||||
|
||||
array = [Array new];
|
||||
for (i = 0; i < 5; i++)
|
||||
[array addObject: [NSNumber numberWithInt: i]];
|
||||
|
||||
inv = [[MethodInvocation alloc]
|
||||
initWithSelector: @selector(print)];
|
||||
[array withObjectsInvoke: inv];
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
Loading…
Reference in a new issue