Tag: cocoa

Notifications for file system changed?

I’m implementing a free space on disk bar where while files are being copied, the free space bar updates. I need some way of being notified of file system changes. What’s the best way to go about doing this?

Convert NSString to NSDictionary

Is there a way to get an NSDictionary back from the string created via its description method? Given this code: NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@”value 1″, @”value 2″, nil] forKeys:[NSArray arrayWithObjects:@”key 1″, @”key 2″, nil]]; NSString *dictionaryString = [dictionary description]; NSLog(dictionaryString); Which makes this output: { “key 1” = “value 1”; “key 2” = […]

Call a method on every word in NSString

I would like to loop through an NSString and call a custom function on every word that has certain criterion (For example, “has 2 ‘L’s”). I was wondering what the best way of approaching that was. Should I use Find/Replace patterns? Blocks? -(NSString *)convert:(NSString *)wordToConvert{ /// This I have already written Return finalWord; } -(NSString […]

Syncing a .plist file with iCloud

I am trying to work out how to sync a .plist file I have in the “Application Support” folder in my Sandboxed app for the Mac. I know I could use the iCloud key value store, but there is a limit of 64KB per app, which may or may not be hit depending on how […]

Rounded NSView in a Transparent Window

I’m trying to make a transparent NSWindow with a rounded view in there. I’m trying to have a rounded view with a transparent window. This is what it looks like now: (see the little dots in the corners) Here’s another example with the border radius set to 10px (set in NSView drawRect): I am using […]

Getting Initial View Controller from Storyboard inside the App Delegate

I am trying to access the initial viewcontroller of my storyboard. It is a navigation controller which is wired up to a second viewcontroller via a seque. So after application did finish launching I want to directly show viewController that is connected through the segue. I tried it out with code like this but it […]

How to find Bundle Identifier from known PID?

I have the pid (process identifier) of an arbitrary running process. How can I find the bundle identifier (if any) of the associated application?

How to detect if NSURLConnection's sendSynchronousRequest:returningResponse:error: ended up being timed out or other error

I use NSURLConnection’s sendSynchronousRequest:returningResponse:error: method (in a separate NSOperation thread) to connect to external server to retreive data. How do I know if the operation ended timed out, or some other network error?

How to draw an inline style label (or button) inside NSMenuItem

When App Store has updates, it shows an inline style element in the menu item, like ‘1 new’ in the screenshot below: Another place we can see this kind of menu is 10.10 Yosemite’s share menu. When you install any app that adds a new share extension, the ‘More’ item from the share menu will […]

How to implement the two-finger swipe gesture in Cocoa to go back and forward?

Several applications like Safari and the Finder go back and forward when you swipe with two fingers on your Magic Mouse (or with three fingers on your Magic Trackpad). How would I implement this in my Cocoa application? What classes are available?