• 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: Getting resource for key (Swift)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting resource for key (Swift)


  • Subject: Re: Getting resource for key (Swift)
  • From: "Jan E. Schotsman" <email@hidden>
  • Date: Tue, 21 Jul 2015 10:48:20 +0200


On Jul 20, 2015, at 9:37 PM, Charles Srstka wrote:

This is, in a nutshell, how I do it:

let url = ...

do {
    var isAliasAny: AnyObject? = nil
    try url.getResourceValue(&isAliasAny, forKey: NSURLIsAliasFileKey)

    if let isAlias = isAliasAny as? NSNumber {
        print("is alias: \(isAlias.boolValue)")
    } else {
	throw NSCocoaError.FileReadUnknownError
    }
} catch {
    print("file object inspection failed: \(error)")
}

So I just needed to replace "Bool?" by "AnyObject?"

This compiles:

	var err:NSError?
	var value:AnyObject?

var gotValue = fileObject.getResourceValue( &value, forKey: NSURLIsAliasFileKey, error: &err );
	if gotValue
		{
		var isAliasFile = (value as! Bool?)!
		}
else { if let error = err { println("file object inspection failed: \ (error.localizedDescription)") }}

These punctuation marks are becoming fun(ny)

Jan E.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Getting resource for key (Swift)
      • From: Jens Alfke <email@hidden>
References: 
 >Getting resource for key (Swift) (From: "Jan E. Schotsman" <email@hidden>)
 >Re: Getting resource for key (Swift) (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: OsX - HTTP resource load blocked
  • Next by Date: Has anyone used Dubrovnik?
  • Previous by thread: Re: Getting resource for key (Swift)
  • Next by thread: Re: Getting resource for key (Swift)
  • Index(es):
    • Date
    • Thread