• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do you receive a BOOL from a method returning BOOL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Ricky Sharp <email@hidden>
  • Date: Sat, 18 Dec 2004 09:52:11 -0600


On Dec 18, 2004, at 9:02 AM, BK [address used for mailing lists only] 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]];

What type is 'res' here?

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.

From the looks here, are you attempting to send the is10digitNANPA: message to your local variable 'res' which is of type BOOL?


If so, it's probably the case where res is initialized to a value of 0 (NULL). Sending a message to NULL then results in an assignment of NULL to res.

[BOOL someMethodReturningBOOL];

doesn't work because BOOL is not a a class.

Hmm. I think you should read up on some of the basics.

I could do something like this ...

if (someMethodReturningBOOL)
	return Yes;
else
	return NO;

but that would seem a bit of a kludge.

This is a valid solution, but yes, a bit overkill. Depending upon where your method lives, you'd have something like:


- (BOOL)foo
{
	return [self someMethodReturningBOOL];
}

If someMethodReturningBOOL is a class method...

- (BOOL)foo
{
	return [MyClass someMethodReturningBOOL];
}

or if its a message that can be sent to some instance...

- (BOOL)foo
{
	return [someInstance someMethodReturningBOOL];
}

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
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


  • Follow-Ups:
    • Re: How do you receive a BOOL from a method returning BOOL
      • From: "BK [address used for mailing lists only]" <email@hidden>
References: 
 >How do you receive a BOOL from a method returning BOOL (From: "BK [address used for mailing lists only]" <email@hidden>)

  • Prev by Date: Re: How to draw and image and a Title in the same cell of a Menu item
  • Next by Date: Re: How do you receive a BOOL from a method returning BOOL
  • Previous by thread: How do you receive a BOOL from a method returning BOOL
  • Next by thread: Re: How do you receive a BOOL from a method returning BOOL
  • Index(es):
    • Date
    • Thread