Top "Cocoa" questions

Cocoa is Apple's application-development framework for macOS, consisting of Foundation, Application Kit, and Core Data.

Get file path and URL for file in temp directory

I'm trying to get the file path of a file called "temp.pdf" which is located in the NSTemporaryDirectory folder (…

objective-c ios cocoa nsbundle
Getting thread id of current method call

Is there a way to print out the current thread id on which the current method is executing on? (objective-c …

iphone objective-c cocoa multithreading
How do I determine the OS version at runtime in OS X or iOS (without using Gestalt)?

The Gestalt() function located in CarbonCore/OSUtils.h has been deprecated as of OS X 10.8 Mountain Lion. I often use …

ios macos cocoa macos-carbon
dispatch_sync vs. dispatch_async on main queue

Bear with me, this is going to take some explaining. I have a function that looks like the one below. …

objective-c cocoa core-data grand-central-dispatch objective-c-blocks
2D arrays using NSMutableArray

I need to create a mutable two-dimensional array in Objective-C. For example I have: NSMutableArray *sections; NSMutableArray *rows; Each item …

objective-c cocoa cocoa-touch multidimensional-array nsmutablearray
Extracting a string with substringWithRange: gives "index out of bounds"

When I try to extract a string from a larger string it gives me a range or index out of …

objective-c cocoa nsstring nsrange
Removing all CALayer's sublayers

I have trouble with deleting all of layer's sublayers. I currently do this manually, but that brings unnecessary clutter. I …

objective-c cocoa core-animation
When is it better to use an NSSet over an NSArray?

I have used NSSets many times in my apps, but I have never created one myself. When is it better …

ios objective-c arrays cocoa cocoa-touch
How do I create a Cocoa window programmatically?

My Cocoa app needs some small dynamically generated windows. How can I programmatically create Cocoa windows at runtime? This is …

objective-c cocoa nswindow