Questions tagged [cocoa]

Cocoa is Apple's application-development framework for macOS, consisting of Foundation, Application Kit, and Core Data. Use the "cocoa-touch" tag for iOS questions.

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

The Cocoa frameworks consist of libraries, APIs and runtimes that form the development layer for all of macOS.

Related tags

Debugging Techniques

Cocoa programs can be debugged with many techniques and tools, both general and specific to Objective-C, Xcode and macOS.

External Resources

General Resources on SO

Memory Management

More information

39610 questions
14
votes
1 answer

Mac Quick Look Preview in an NSView or NSImage?

I am looking for a way (public or otherwise) to get an NSView, NSImage, CGImageRef, etc that shows the QuickLook preview for a file. Essentially the equivalent of QLThumbnailImageCreate() but for the preview. The public APIs I can find do not…
Niko Matsakis
  • 235
  • 2
  • 6
14
votes
4 answers

Support NSDocument changes in an external editor?

I have an NSDocument with some simple code: - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError { self.string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; return YES; } If I change…
Sam Soffes
  • 14,831
  • 9
  • 76
  • 80
14
votes
2 answers

How can we bounce the dock icon on the Mac?

How can we bounce the dock icon of our application?
Amit Battan
  • 305
  • 3
  • 12
14
votes
3 answers

NSSortDescriptor and nil values

I'm using an NSSortDescriptor to sort NSDate objects in an ascending order. However, I need nil dates to be at the bottom of the list, whereas at the moment they come at the top.
Daniel Wood
  • 4,487
  • 3
  • 38
  • 36
14
votes
8 answers

How to get serial number from Mac hard disks?

Is there an easy way to get the serial number of all the hard disks in a Mac using an API? Basically, I'm looking for a unique identifier for the hard disk with which I can figure out whether the hard disk has been used (or referred to) by my…
Girish Kolari
  • 2,515
  • 2
  • 24
  • 34
14
votes
7 answers

How to get list of all applications currently running and visible in Dock for Mac OS X programming?

I need to know which applications are running and have an active window. Something similar must be what's in the 'command + tab' hotkey switcher. When I run some code like this: NSWorkspace * ws = [NSWorkspace sharedWorkspace]; NSArray * apps = [ws…
Cam
  • 988
  • 1
  • 12
  • 25
14
votes
3 answers

Objective-c asynchronous communication: target/action or delegation pattern?

I'm dealing with some asynchronous communication situations (Event-driven XML parsing, NSURLConnection response processing, etc.). I'll try to briefly explain my problem: In my current scenario, there is a service provider (that can talk to a xml…
Lio
  • 4,225
  • 4
  • 33
  • 40
14
votes
3 answers

When should I use Strong vs Weak for IBOutlets (further clarification)

I thought I understood it clearly from this question --> Should IBOutlets be strong or weak under ARC? but I recently had a discussion which left me totally confused. Can someone just confirm if the following is correct? (if this is a duplicate I…
Just a coder
  • 15,480
  • 16
  • 85
  • 138
14
votes
1 answer

Debugging a NULL CGContext under Cocoa/Carbon

During the execution of my program I'm getting the following output in the XCode debugging console: : CGContextSetTextMatrix: invalid context 0x0 I have no idea where in the application this NULL-context is being passed to the OS. Anyone…
fbrereto
  • 35,429
  • 19
  • 126
  • 178
14
votes
9 answers

What describes nil best? What's that really?

Currently I understand it as a kind of "empty object". But what's it really?
openfrog
  • 40,201
  • 65
  • 225
  • 373
14
votes
1 answer

NSPanel in "Non-Activating"-Mode does not always show correct cursors

I've created a simple Cocoa-Application in XCode 4.6 with an NSPanel instead of the default NSWindow. When I enable the Non-Activating option and start the application everything works fine: The panel is displayed in front of everything else and…
jimmyorpheus
  • 283
  • 1
  • 6
14
votes
2 answers

Displaying fixed and editable items in a Source List

Background I am creating a Source List for my application and I want it structured in a way similar to that of iTunes, with two types of items: "Fixed" items – these do not change and can't be moved around – at the top Editable items underneath,…
Alex Rozanski
  • 37,815
  • 10
  • 68
  • 69
14
votes
1 answer

Handling NSError when reading from file?

I am just curious if I am doing this right. NSString *fileContents; NSError *fileError = nil; fileContents = [[NSString stringWithContentsOfFile:fileOnDisk encoding:NSMacOSRomanStringEncoding …
fuzzygoat
  • 26,573
  • 48
  • 165
  • 294
14
votes
2 answers

Notification when display gets connected or disconnected

I'm working on an OS X application that displays custom windows on all available spaces of all the connected displays. I can get an array of the available display objects by calling [NSScreen screens]. What I'm currently missing is a way of telling…
Gabor
  • 278
  • 4
  • 14
14
votes
5 answers

NSMutableArray destruction

I have an array NSMutableArray with happy objects. These objects viciously turn on (leak) me whenever I try to clear the array of all the objects and repopulate it. It's allocated in the init function like so self.list = [NSMutableArray array]; The…
SageAMDP
  • 441
  • 2
  • 6
  • 15
1 2 3
99
100