• 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: Checking on the existence of a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking on the existence of a file


  • Subject: Re: Checking on the existence of a file
  • From: Harald E Brandt <email@hidden>
  • Date: Mon, 03 Dec 2012 21:32:52 +0100

On 2 dec 2012, at 08:09, Shane Stanley <email@hidden> wrote:

On 02/12/2012, at 1:10 PM, Shane Stanley <email@hidden> wrote:

I guess to be a fair comparison on both counts you should probably tack on "as boolean" -- although I suspect the effect will be negligible.

Wake up! Of course you don't have to do any such thing...

In this particular case, I knew that fileExistsAtPath_ returned an AS boolean into flag (because I had tested my code, and I wanted it to be minimal).
But I do admit that I do not know the rules when such coercion is automatic. NSFileManager methods that return BOOL seem to always return booleans into AS, despite BOOL is specified internally as type char. For NSString this is not so, but one can "cheat" by omitting the parentheses on parameterless methods:

set myString to current application's NSString's stringWithString_("/usr")
myString's isEqualToString_("/usr") --> 1
myString's hasPrefix_("/") --> 1
myString's isAbsolutePath() --> 1
myString's isAbsolutePath --> true
myString's boolValue() --> 0
myString's boolValue --> false

Although explicit coercion to boolean is safest, I am curious to learn the rules, and why e.g NSFileManager does not need coercion.

--heb
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Checking on the existence of a file
      • From: Shane Stanley <email@hidden>
References: 
 >Re: Checking on the existence of a file (From: Harald E Brandt <email@hidden>)
 >Re: Checking on the existence of a file (From: Shane Stanley <email@hidden>)
 >Re: Checking on the existence of a file (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: How do I save an array in plist?
  • Next by Date: Re: Checking on the existence of a file
  • Previous by thread: Re: Checking on the existence of a file
  • Next by thread: Re: Checking on the existence of a file
  • Index(es):
    • Date
    • Thread