What is the best Core Image filter to produce black and white effects?

– (UIImage *)imageBlackAndWhite { CIImage *beginImage = [CIImage imageWithCGImage:self.CGImage]; CIImage *blackAndWhite = [CIFilter filterWithName:@”CIColorControls” keysAndValues:kCIInputImageKey, beginImage, @”inputBrightness”, [NSNumber numberWithFloat:0.0], @”inputContrast”, [NSNumber numberWithFloat:1.1], @”inputSaturation”, [NSNumber numberWithFloat:0.0], nil].outputImage; CIImage *output = [CIFilter filterWithName:@”CIExposureAdjust” keysAndValues:kCIInputImageKey, blackAndWhite, @”inputEV”, [NSNumber numberWithFloat:0.7], nil].outputImage; CIContext *context = [CIContext contextWithOptions:nil]; CGImageRef cgiimage = [context createCGImage:output fromRect:output.extent]; //UIImage *newImage = [UIImage imageWithCGImage:cgiimage]; UIImage *newImage … Read more

How to create a NSString from a format string like @”xxx=%@, yyy=%@” and a NSArray of objects?

It is actually not hard to create a va_list from an NSArray. See Matt Gallagher’s excellent article on the subject. Here is an NSString category to do what you want: @interface NSString (NSArrayFormatExtension) + (id)stringWithFormat:(NSString *)format array:(NSArray*) arguments; @end @implementation NSString (NSArrayFormatExtension) + (id)stringWithFormat:(NSString *)format array:(NSArray*) arguments { char *argList = (char *)malloc(sizeof(NSString *) * … Read more

Temporary file path using swift

Apple has been trying to move away from path-as-string and into NSURL. Here’s one way: Swift 3: let directory = NSTemporaryDirectory() let fileName = NSUUID().uuidString // This returns a URL? even though it is an NSURL class method let fullURL = NSURL.fileURL(withPathComponents: [directory, fileName]) Swift 2: let directory = NSTemporaryDirectory() let fileName = NSUUID().UUIDString let … Read more

Creating feature in mac app to override the users security setting

Launch System Preferences from the Apple menu. Choose “Security & Privacy” and then click the “General” tab, followed by clicking the lock icon in the corner to unlock the settings. Look for “Allow applications downloaded from:” and choose “Anywhere”. Accept the security warning and allow. Note that you should be careful and aware that now … Read more

easing c++ to objective-c/cocoa bridging via metaprogramming?

I didn’t find anything satisfactory and came up with a prototype that, given the following informal protocol: – (NSString*)concatString:(NSString*)s1 withString:(NSString*)s2; and this C++ code: struct CppClass { std::string concatStrings(const std::string& s1, const std::string& s2) const { return s1+s2; } }; std::string concatStrings(const std::string& s1, const std::string& s2) { return s1+s2; } allows creating and passing … Read more

NSWindowController/NSViewController “Presentation” setting in Storyboard

The presentation style affects “Show” segues. Possibly it affects other segues too, but I only tested a Show segue. I tested on OS X 10.10.5 (Yosemite) with Xcode 7.1.1. If a window controller’s presentation style is “Multiple” (the default), then a Show segue to the window controller always loads a new instance of the window … Read more

Difference between NSWindowController Vs NSViewController

With iPhone SDK and Leopard SDK, they introduced view controllers, or NSViewController and UIViewController. As their names suggest what they do is to manage views The view controllers are for managing views. Current trend in UI design is Single Window, Multiple View. What it means is that there is one Window and inside of it, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)