NSWindow with round corners and shadow

Update I realised old approach was not able to create precise round corner. So I updated example to make precise round corner. window1.backgroundColor = NSColor.whiteColor() window1.opaque = false window1.styleMask = NSResizableWindowMask | NSTitledWindowMask | NSFullSizeContentViewWindowMask window1.movableByWindowBackground = true window1.titlebarAppearsTransparent = true window1.titleVisibility = .Hidden window1.showsToolbarButton = false window1.standardWindowButton(NSWindowButton.FullScreenButton)?.hidden = true window1.standardWindowButton(NSWindowButton.MiniaturizeButton)?.hidden = true window1.standardWindowButton(NSWindowButton.CloseButton)?.hidden = … Read more

Property vs. instance variable

Properties are just setters and getters for ivars and should (almost) always be used instead of direct access. @interface APerson : NSObject { // NSString *_name; // necessary for legacy runtime } @property(readwrite) NSString *name; @end @implementation APerson @synthesize name; // use name = _name for legacy runtime @end @synthesize creates in this case those … Read more

“First Responder” – Did I get that right?

Right overall picture, wrong implementation details in the first paragraph. A “First Responder” in a NibFile is an Object … No, actually, First Responder is nil. Connecting a UI control (e.g., button) to First Responder in a nib is equivalent to [control setTarget:nil] in code. The reason for the First Responder fake-object in the nib … Read more

Which method of checking to see if a NSDictionary contains a particular key is faster?

A hash lookup should be faster in general than going over all the dictionary keys, creating an array from them (memory allocation is relatively expensive) and then searching the array (which can’t even be a binary search since the array is not sorted). For the sake of science, though, I made two executables that just … Read more

How can I easily save the Window size and position state using Obj-C?

Put a name that is unique to that window (e.g. “MainWindow” or “PrefsWindow”) in the Autosave field under Attributes in Interface Builder. It will then have its location saved in your User Defaults automatically. To set the Autosave name programmatically, use -setFrameAutosaveName:. You may want to do this if you have a document-based App or … Read more

Tinting a grayscale NSImage (or CIImage)

The above solution didn’t work for me. But this much easier solution works great for me – (NSImage *)imageTintedWithColor:(NSColor *)tint { NSImage *image = [self copy]; if (tint) { [image lockFocus]; [tint set]; NSRect imageRect = {NSZeroPoint, [image size]}; NSRectFillUsingOperation(imageRect, NSCompositeSourceIn); [image unlockFocus]; } return image; }

How to use NSIndexSet

it would be the proper way: NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)]; or you can use the NSMutableIndexSet for the random indexes: NSMutableIndexSet *mutableIndexSet = [[NSMutableIndexSet alloc] init]; [mutableIndexSet addIndex:0]; [mutableIndexSet addIndex:2]; [mutableIndexSet addIndex:9]; etc.

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