This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)normalizeFilename:(NSString *)filename; | |
{ | |
NSMutableString *result = [filename mutableCopy]; | |
CFStringTransform((CFMutableStringRef)buffer, | |
NULL, | |
CFSTR("Any-Latin; Latin-ASCII"), | |
false); | |
return [result autorelease]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A single slash takes us back to the host's root directory, | |
// discarding any components after the path. | |
// Then make absolute so callers don't have to worry about any | |
// side-effects of working with relative URL objects. | |
return [[NSURL URLWithString:@"/" relativeToURL:url] absoluteURL]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; | |
[formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]]; | |
[formatter setDateFormat:@"MMM d yyyy"]; | |
[formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; | |
NSString *string = @__DATE__; | |
NSDate *buildDate = [formatter dateFromString:string]; | |
[formatter release]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CFStringRef escaped = CFURLCreateStringByAddingPercentEscapes(NULL, | |
(CFStringRef)path, | |
NULL, | |
CFSTR("@:/?#"), | |
kCFStringEncodingUTF8); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CFStringRef escaped = CFURLCreateStringByAddingPercentEscapes(NULL, | |
(CFStringRef)query, | |
NULL, | |
CFSTR("+#"), | |
kCFStringEncodingUTF8); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CFStringRef escaped = CFURLCreateStringByAddingPercentEscapes(NULL, | |
(CFStringRef)path, | |
NULL, | |
CFSTR(";?#"), | |
kCFStringEncodingUTF8); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *escaped = [path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This code is devious and perhaps even evil. Manages a "stack" of completion | |
* handlers by actually only having a single block. When the block runs, it | |
* replaces itself with the next one down the stack. | |
*/ | |
- (void)pushCompletionHandler:(void (^)(NSError*))block; | |
{ | |
NSParameterAssert(block); | |
id previousHandler = _completionHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface Bar : NSManagedObject | |
@property NSManagedObject *foo; | |
@end | |
@implementation Bar | |
@dynamic foo; | |
- (BOOL)isFoo { return NO; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8 | |
#define NSURLPathKey @"_NSURLPathKey" | |
#endif | |
NSDictionary *values = [[NSURL resourceValuesForKeys:@[NSURLPathKey] | |
fromBookmarkData:bookmarkData] | |
NSString *path = [values objectForKey:NSURLPathKey]; | |
#undef NSURLPathKey |