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

Keep order of NSArray with CloudKit

I'm currently designing a CloudKit based syncing-solution and I wondered what the best way is to keep the order of a list (an array in my case) of cloud items (CKRecord objects) consistent. Apple advises against holding a reference to child objects…
JanApotheker
  • 1,746
  • 1
  • 17
  • 23
14
votes
4 answers

How to hide the initial window on start with OS X storyboards

I am creating an OS X status bar application, so I want the application to start hidden. I have created a "storyboard" application, and the initial window always shows up, even if "Visible at launch" is unchecked (was unchecked by default). Note:…
Matthieu Napoli
  • 48,448
  • 45
  • 173
  • 261
14
votes
3 answers

Generate vCard from AddressBook.framework

I'm utilising the AddressBook.framework in my iPhone app, and I'd like to replicate something along the lines of the share feature in Contacts.app. This basically attach's a specific contacts vCard to an email. As far as I know, there is nothing in…
Oliver
  • 1,279
  • 5
  • 14
  • 20
14
votes
1 answer

What does kCGWindowSharingState actually do?

If you call CGWindowListCopyWindowInfo(), the CFDictionaryRef that you get back contains a number of keys and values. One of these is kCGWindowSharingState, which has three possible values: Window Sharing Constants Specifies whether and how windows…
Mark Bessey
  • 19,598
  • 4
  • 47
  • 69
14
votes
4 answers

Any way to ask a method for its name?

I'm trying to debug an iPhone app I'm working on, and the idea of adding fifty NSLog statements to the various source files gives me the willies. What I'd like to do is write a pair of statements, say NSString *methodName = [self…
Andy
  • 576
  • 1
  • 9
  • 23
14
votes
1 answer

addGlobalMonitorForEventsMatchingMask not working

I am having trouble with getting an assistive-enabled application (XCode in the development case) to capture global keyDown events. I've seen lots of code examples like the below, but this doesn't work for me on 10.9.4. #import…
James Waldrop
  • 545
  • 4
  • 17
14
votes
9 answers

Problem dismissing multiple modal view controllers

I am having trouble getting my modal view controllers to display properly. I have a parent view controller that is the delegate for modal view A. In modal view A I am presenting modal view B, and having the delegate dimiss modal view A. When modal…
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
14
votes
4 answers

Do I need to release a copied NSObjects - Objective-c

I was wondering if I need to release a copied NSObject? For example, I create only one dictionary that I copy into an array: Code: for (int num = 0; num < [object count]; num++) { [dictionary setObject:[object objectAtIndex:num] forKey:@"x"]; …
Nate
  • 7,606
  • 23
  • 72
  • 124
14
votes
4 answers

Failed to connect (storyboard) outlet from (NSApplication) to (NSNibExternalObjectPlaceholder) error in Cocoa and storyboard

I've tried to build a sample Cocoa app on which I want to connect UI components put on storyboard to ViewController.swift as either an IBOutlet or IBAction. However, when I tried to control-drag the UI components on storyboard (such as NSButton) to…
Blaszard
  • 30,954
  • 51
  • 153
  • 233
14
votes
3 answers

How can I get a list of all windows, currently on the screen, in swift?

How can I get a list of all windows, currently on the screen, in swift? (all examples are preceded by import Cocoa) In objective-c I can run the following code successfully: CFArrayRef windowList =…
m3o
  • 3,881
  • 3
  • 35
  • 56
14
votes
3 answers

swift: forced type modifier "!" - why is (was) it used in UIKit API (now anachronistic)

Edit: The intent of this question was to understand the use of the implicit optional operator "!" in the early UIKit API updates, specifically if a function was declared as returning a type expected to be non optional, why use optional at all, and…
Chris Conover
  • 8,889
  • 5
  • 52
  • 68
14
votes
1 answer

Learning to code on iOS - swift vs Objective C dilemna

I have just finished a year of university and learnt how to write nice applications with C++, OpenGL and Qt. I was just about to start learning Objective C and Cocoa. This seemed optimal to develop iOS & Mac apps since Objective C was, like C++, a…
alexbcg
  • 193
  • 1
  • 1
  • 6
14
votes
3 answers

iOS use of NSColor versus UIColor?

What's the difference between UIColor and NSColor, and when would one use each? I came across NSColor while trying to figure out UIColor uses for attributed strings in iOS. I understand the use of UIColor for the UIKit and such, but I don't think…
Fleija
  • 290
  • 5
  • 10
14
votes
2 answers

Simulating key press events in Mac OS X

I'm writing an app where I need to simulate key press events on a Mac, given a code that represents each key. It seems I need to use the CGEventCreateKeyboardEvent function to create the event. The problem is that this function needs a Mac keycode,…
Thomi
  • 11,647
  • 13
  • 72
  • 110
14
votes
2 answers

App crashes when I create a NSDictionary with integer as Object

Always when I try to set an integer as Object in a NSDictionary the program crashes without a message (nothing in the console). What is wrong in this code? : NSString *string = @"foo"; int number = 1; NSDictionary *params = [NSDictionary…
Flocked
  • 1,898
  • 2
  • 36
  • 57
1 2 3
99
100