Problems with NSInvocation - arguments misplaced? [long]
Problems with NSInvocation - arguments misplaced? [long]
- Subject: Problems with NSInvocation - arguments misplaced? [long]
- From: j o a r <email@hidden>
- Date: Tue, 14 Aug 2001 14:50:03 +0200
Hello,
I try to pass two strings to a method through the use of NSInvocation.
First off, I'm not yet doing anything fancy - like handing the
invocation over to some other thread, or slipping into the next run loop
or anything. For all practical purposes I might still use a straight
method call, but I was trying to warm up a bit before getting there...
This is what I get when the invocation is invoked on my method. The
first line is a print out of the parameters passed to the method, the
second one is a follow up error:
method:
NSLog(@"Enter: moveItemAtPath: %@ toPath: %@", theItemOldPath,
theItemNewPath);
//************************************************************************
********************
Aug 14 14:03:14 MyApp[2211] Enter: moveItemAtPath: NSPathStore2 toPath:
NSCFString
Aug 14 14:03:14 MyApp[2211] *** +[NSPathStore2 pathComponents]: selector
not recognized
//************************************************************************
********************
I would have expected to se this type of print out:
//************************************************************************
********************
Aug 14 14:03:14 MyApp[2211] Enter: moveItemAtPath: /my/path1 toPath:
/my/path2
//************************************************************************
********************
The strings are fine when I put them in the invocation object, and I
also retain them for good meassure - even though I don't think it is
necessary as long as I don't leave the current run loop. Like this:
//************************************************************************
********************
[theInvocation setArgument: path1 atIndex:2];
[theInvocation setArgument: path2 atIndex:3];
NSLog(@"path1: %@", path1);
NSLog(@"path2: %@", path2);
[theInvocation retainArguments];
//************************************************************************
********************
And here, when I create the invocation, the NSLog outputs prints the
paths just fine.
Any ideas on what could be wrong with my arguments?
Regards,
j o a r
Ps.
I tried to verify that the arguments looked OK in the invocation object
before invoking it, but I think I failed to get the syntax right for
digging them out of the invocation (why does that have to be so
complicated?):
//************************************************************************
********************
void *tempPath1 = (void *)malloc(80);
void * tempPath2 = (void *)malloc(80);
[theInvocation getArgument:tempPath1 atIndex:2];
[theInvocation getArgument:tempPath2 atIndex:3];
NSLog(@"tempPath1: %@", (NSString *)tempPath1);
NSLog(@"tempPath1: %@", (NSString *)tempPath2);
//************************************************************************
********************
I'm not really sure on how to create the buffer for the getAttributes
method - could someone perhaps advice?
Ds.