Re: How do you receive a BOOL from a method returning BOOL
Re: How do you receive a BOOL from a method returning BOOL
- Subject: Re: How do you receive a BOOL from a method returning BOOL
- From: Tim Hewett <email@hidden>
- Date: Sat, 18 Dec 2004 19:47:58 +0000
Hello,
Try using NSNumber. For example, you can use:
return [NSNumber numberWithBool:[res is10digitNANPA:[aString
substringFromIndex:index]]];
This encapsulates a BOOL in an object. I am not familiar
with Applescript but from what you say it can cope with returns
of type NSString so perhaps it is expecting all returns to be
objects. Base types such as int (which is essentially what BOOL
is), float, char etc are not objects so that might be the problem.
However it appears that previously you have successfully
returned "YES", which is not an object either... Maybe my suggestion
will help in some respect anyway.
Tim.
On 18 Dec 2004, at 15:53, email@hidden wrote:
I have written a few Objective-C methods which I call from AppleScript
Studio apps.
So far I have always returned either a literal like 'return YES;' or a
local variable 'return myLocalVar;' or the result of a method call
where I could use the class name as the receiver such as in
return [NSString someMethodReturningNSString];
but now I have run into a very silly problem trying to return the
result of a method call that returns a BOOL. It would seem trivial but
I can't seem to work out how to do this. My code looks like this ...
return [res is10digitNANPA:[aString substringFromIndex:index]];
but that doesn't work. I have alo tried this ...
BOOL res;
...
res = [res is10digitNANPA:[aString substringFromIndex:index]];
NSLog(@"res: %@", res);
return res;
and it shows me that res is NULL.
[BOOL someMethodReturningBOOL];
doesn't work because BOOL is not a a class.
I could do something like this ...
if (someMethodReturningBOOL)
return Yes;
else
return NO;
but that would seem a bit of a kludge.
so how do you properly return the result of a method that returns BOOL?
thanks in advance
rgds
bk
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden