forked from orta/tumblrclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNSURL_UrlFromFSRef.m
32 lines (27 loc) · 926 Bytes
/
NSURL_UrlFromFSRef.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// NSURL_UrlFromFSRef.m
// Tumblg
// From NSURL+NDCarbonUtilities.h
// @header NSURL+NDCarbonUtilities
// @abstract Provides method for interacting with Carbon APIs.
// @discussion The methods in <tt>NSURL(NDCarbonUtilities)</tt> are simply wrappers for functions that can bew found within the Carbon API.
// @copyright © 2007 Nathan Day. All rights reserved.
//
#import "NSURL_UrlFromFSRef.h"
@implementation NSURL (NDCarbonUtilities)
/*
+ URLWithFSRef:
*/
+ (NSURL *)URLWithFSRef:(const FSRef *)aFsRef
{
CFURLRef theURL = CFURLCreateFromFSRef( kCFAllocatorDefault, aFsRef );
/* With garbage collection, toll free bridging is not so perfect; must always match CFCreate...() and CFRelease().
Put another way, don't autorelease objects created by CFCreate...() functions */
#ifndef __OBJC_GC__
[(NSURL *)theURL autorelease];
#else
CFMakeCollectable( theURL );
#endif
return (NSURL*)theURL;
}
@end