I’ve spent quite amount of time googling a way to retrieve a path to the standard User’s Downloads folder. Surprisingly, a solution has been hard to find (at least for me :). And here is the simplest snippet I’ve come up with:
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory,
NSUserDomainMask,
YES);
NSString *downloadsFolder = [searchPaths lastObject];
Hope it will save somebody their valuable time.
Categories: Cocoa
Tagged: Cocoa, Code Snippets, Development
Some time ago I was playing with value transformers and, finally, I found a kind of my own way to declare and register them. There is nothing special but I’m going to describe it here using some code in test purposes :)
The most important part — value transformer:
//
// PlayPauseLabelTransformer.h
//
@interface PlayPauseLabelTransformer
+ (void)setup;
@end
//
// PlayPauseLabelTransformer.m
//
@implementation PlayPauseLabelTransformer
+ (Class)transformedValueClass {
return [NSString class];
}
- (id)transformedValue:(id)value {
BOOL isPlaying = [value boolValue];
return (isPlaying
? NSLocalizedString(@"Pause",
@"Label for Pause button")
: NSLocalizedString(@"Play",
@"Label for Play button"));
}
+ (void)setup {
[self setValueTransformer:[self new]
forName:NSStringFromClass(self)];
}
@end
Registration:
//
// PlaybackViewController.m
//
#import "PlayPauseLabelTransformer.h"
@implementation PlaybackViewController
+ (void)initialize {
if (self != [PlaybackViewController class]) return;
[PlayPauseLabelTransformer setup];
}
That’s it. Value transformer is ready to be used in the IB Inspector:

Categories: Cocoa
Tagged: Cocoa, Code Snippets, Development, KVB/KVO, Test, UI
Hi. I’m an UI developer who wants to become a professional mac developer :)
To be honest, I’m not sure if I need this blog. But sometimes I really want to write Something. And I really hope that this place will become my friend for a long time. Let’s go…
Categories: Uncategorized
Tagged: Blog, Hello World