Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1408 votes
39 answers
514k views

How can I check for an active Internet connection on iOS or macOS?

I would like to check to see if I have an Internet connection on iOS using the Cocoa Touch libraries or on macOS using the Cocoa libraries. I came up with a way to do this using an NSURL. The way I ...
Brock Woolf's user avatar
  • 47.1k
1323 votes
82 answers
1.0m views

Xcode - How to fix 'NSUnknownKeyException', Reason: "… this class is not key value coding-compliant for the key X" error?

I'm trying to link a UILabel with an IBOutlet created in my class. My application is crashing with the following error" *** Terminating app due to uncaught exception 'NSUnknownKeyException', ...
338 votes
89 answers
241k views

Hidden Features of Xcode

With a huge influx of newbies to Xcode, I'm sure there are lots of Xcode tips and tricks to be shared. What are yours?
317 votes
4 answers
95k views

Core Data vs SQLite 3 [closed]

I am already quite familiar with relational databases and have used SQLite (and other databases) in the past. However, Core Data has a certain allure, so I am considering spending some time to learn ...
Jason Medeiros's user avatar
212 votes
29 answers
536k views

Xcode build failure "Undefined symbols for architecture x86_64"

An Xcode beginner's question: It is my first experience with Xcode 4.6.3. I am trying to write a very simple console program, that searches for paired BT devices and prints them to an NSLog. It ...
RisingSun's user avatar
  • 2,447
211 votes
12 answers
136k views

Execute a terminal command from a Cocoa app

How can I execute a terminal command (like grep) from my Objective-C Cocoa application?
lostInTransit's user avatar
178 votes
13 answers
43k views

What is the best way to solve an Objective-C namespace collision?

Objective-C has no namespaces; it's much like C, everything is within one global namespace. Common practice is to prefix classes with initials, e.g. if you are working at IBM, you could prefix them ...
Mecki's user avatar
  • 131k
176 votes
6 answers
90k views

How to create a Menubar application for Mac

EDIT: This is a nice ready-made menubar application here (github source) by this answer. I was wondering how to make a menubar application, what are the requirements for that to do so? I saw a ...
MacMac's user avatar
  • 34.9k
170 votes
7 answers
107k views

What's the difference between "bundle display name" and "bundle name" in cocoa application's info plist

Here is a good question: Bundle Name, Executable Name, Product Name...anything else? but I just wonder about the difference between "bundle display name" and "bundle name" in cocoa application's ...
xhan's user avatar
  • 6,217
150 votes
7 answers
87k views

How do you set the text in an NSTextField?

I'm trying to set the text in an NSTextField, but the -setStringValue: and -setTitleWithMnemonic: methods are not working. Any ideas?
Alexsander Akers's user avatar
143 votes
18 answers
127k views

How to manually create icns files using iconutil?

When I'm validating my app I get this error: the application bundle does not contain an icon in ICNS format, containing both a 512x512 and a 512x512@2x image. I use to make the icns icons with ...
Blue's user avatar
  • 2,350
128 votes
3 answers
80k views

How to get Core Data object from specific Object ID?

I can easily get an object's ID in Core Data using the following code: NSManagedObjectID *moID = [managedObject objectID]; However, is there a way to get an object out of the core data store by ...
Jason's user avatar
  • 14.6k
124 votes
2 answers
60k views

Remove autolayout (constraints) in Interface Builder

I'm trying to make my project compatible with Snow Leopard and I am not able to remove the autolayout in the nibs using Interface builder (XCode 4.3 on Lion). Is it possible to remove the constraints ...
Olof's user avatar
  • 5,338
108 votes
23 answers
45k views

Hidden Features of Xcode 4

Now that Xcode 4 is officially released it's time for a follow up to my previous question: Hidden Features of Xcode So what are they? What are those hidden little Xcode 4 hints & tips that you ...
106 votes
4 answers
49k views

Get value from NSTextField

I have an NSTextField and I need to get the field's value into a variable. What's the appropriate method?
anakin's user avatar
  • 1,189
102 votes
9 answers
35k views

Xcode linker error: file too small for architecture x86_64

I'm developing an application in Xcode. When I try to build, this error comes up: ld: in /Users/theodore/Library/Developer/Xcode/DerivedData/Tower-bkpdifuqssebjdgurzmtirbxejnn/Build/Intermediates/...
tbodt's user avatar
  • 16.9k
102 votes
20 answers
130k views

Input from the keyboard in command line application

I am attempting to get the keyboard input for a command line app for the new Apple programming language Swift. I've scanned the docs to no avail. import Foundation println("What is your name?") ??? ...
Chalkers's user avatar
  • 1,953
92 votes
10 answers
41k views

View-based NSTableView with rows that have dynamic heights

I have an application with a view-based NSTableView in it. Inside this table view, I have rows that have cells that have content consisting of a multi-row NSTextField with word-wrap enabled. ...
Jiva DeVoe's user avatar
  • 1,338
92 votes
4 answers
96k views

Are "EXC_BREAKPOINT (SIGTRAP)" exceptions caused by debugging breakpoints?

I have a multithreaded app that is very stable on all my test machines and seems to be stable for almost every one of my users (based on no complaints of crashes). The app crashes frequently for one ...
Dennis's user avatar
  • 1,235
91 votes
7 answers
77k views

How can I set the icon for a Mac Application in Xcode?

I have been learning a lot about writing Objective-C code and designing in Interface Builder and I wanted to set icons for my simple programs. I added the same JPG to all the size fields in Icon ...
kmikael's user avatar
  • 5,002
90 votes
7 answers
48k views

How to hide the Dock icon

I want to make a preference for hiding the Dock icon and showing an NSStatusItem. I can create the StatusItem but I don't know how to remove the icon from Dock. :-/ Any ideas?
papr's user avatar
  • 4,767
84 votes
5 answers
40k views

Where is a Mac Application's NSUserDefaults Data Stored?

I am using NSUserDefaults to store some data in my application. NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; [prefs setObject:@"dummy string" forKey:@"lastValue"]; [prefs ...
ahmadbaig's user avatar
  • 1,086
82 votes
9 answers
59k views

How to save a NSImage as a new file

How can I save a NSImage as a new file (png, jpg, ...) in a certain directory?
burki's user avatar
  • 2,986
80 votes
3 answers
37k views

What is the strong property attribute

I am using the Xcode beta for developers, and am noticing some subtle differences. Among them is a new attribute for declared properties. @property(strong)IBOutlet NSArrayController *arrayControl; ...
Chance Hudson's user avatar
79 votes
11 answers
56k views

NSArray Equivalent of Map

Given an NSArray of NSDictionary objects (containing similar objects and keys) is it possible to write perform a map to an array of specified key? For example, in Ruby it can be done with: array.map(&...
Stussa's user avatar
  • 3,405
79 votes
16 answers
65k views

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 this function to test the version of the OS X operating system at runtime (see ...
Todd Ditchendorf's user avatar
77 votes
19 answers
48k views

How do you convert an iPhone OSStatus code to something useful?

I am getting more than a little sick of this iPhone SDK and its documentation... I am calling AudioConverterNew in the documentation under Returns: it says "returns a status code" ... really... so ...
matt's user avatar
  • 4,164
76 votes
11 answers
103k views

Rounding numbers in Objective-C

I'm trying to do some number rounding and conversion to a string to enhance the output in an Objective-C program. I have a float value that I'd like to round to the nearest .5 and then use it to set ...
Ash's user avatar
  • 2,330
73 votes
1 answer
11k views

Do you need to create an NSAutoreleasePool within a block in GCD?

Normally, if you spawn a background thread or run an NSOperation on an NSOperationQueue you need to create an NSAutoreleasePool for that thread or operation because none exists by default. Does the ...
Brad Larson's user avatar
  • 170k
69 votes
10 answers
68k views

How to get the file size given a path?

I have a path to file contained in an NSString. Is there a method to get its file size?
hekevintran's user avatar
  • 23.4k
68 votes
5 answers
109k views

List of all users and groups

I'm trying to get a list of all users and all groups on Mac OS X 10.5+. How can I do this? For example, the list of all users on my machine should return: _amavisd, _appowner, _appserver, _ard, ...
Dave DeLong's user avatar
67 votes
12 answers
28k views

How to detect if OS X is in dark mode?

My cocoa app has to change its behaviour when run in the new OS X "dark mode". Is there a way to detect if OS X style is set to this mode?
Augustus1's user avatar
  • 705
67 votes
1 answer
2k views

Separate cookie jar per WebView in OS X

I've been trying to achieve the goal of having a unique (not shared) cookie jar per WebView in macOS (cookies management works different for iOS). After reading a lot of StackOverflow questions and ...
Juanjo Conti's user avatar
  • 29.6k
65 votes
6 answers
58k views

Class Foo is implemented in both MyApp and MyAppTestCase. One of the two will be used. Which one is undefined

Recently I started Unit testing my application. This project (in Xcode4) was created without a unit test bundle so I had to set it up. I have followed the steps from here: http://cocoawithlove.com/...
nacho4d's user avatar
  • 44.7k
60 votes
6 answers
39k views

Sample code for creating a NSTextField "label"?

In my desktop Mac OS X app, I'd like to programatically create a NSTextField "label" which has the same behavior and properties as a typical label created in Interface Builder. I usually use (and ...
Todd Ditchendorf's user avatar
58 votes
2 answers
23k views

Send notification to Mountain lion notification center

Can someone give an example of sending a test notification from a Cocoa app to Notifications Center? eg. when I click on an NSButton
haseo98's user avatar
  • 837
57 votes
9 answers
51k views

How to convert an NSData into an NSString Hex string?

When I call -description on an NSData object, I see a pretty Hex string of the NSData object's bytes like: <f6e7cd28 0fc5b5d4 88f8394b af216506 bc1bba86 4d5b483d> I'd like to get this ...
Todd Ditchendorf's user avatar
57 votes
1 answer
1k views

Layer-backed NSView rotation and skewed siblings

I have a strange issue with layer-backed NSView and it's siblings, some of them are not rendered correctly when added into the existing view hierarchy attached to the rotated superview. Below are the ...
Gobra's user avatar
  • 4,261
56 votes
6 answers
12k views

Can I receive a callback whenever an NSPasteboard is written to?

I've read Apple's Pasteboard Programming Guide, but it doesn't answer a particular question I have. I'm trying to write a Cocoa application (for OS X, not iOS) that will keep track of everything that ...
Adrian Petrescu's user avatar
55 votes
15 answers
61k views

How do you fix "code object is not signed at all In subcomponent:" in Xcode 6, Mac OS X Yosemite or Mavericks?

When compiling my application I'm getting the following error: CodeSign /Users/pupeno/Library/Developer/Xcode/DerivedData/ProjectX-cynmgyozflnwbpamwnpsnhgshuyq/Build/Products/Debug/Project\ X.app ...
Pablo Fernandez's user avatar
55 votes
7 answers
17k views

How to listen to global hotkeys with Swift in a macOS app?

I'm trying to have a handler in my Mac OS X app written in Swift for a global (system-wide) hotkey combo but I just cannot find proper documentation for it. I've read that I'd have to mess around in ...
Csaba Okrona's user avatar
54 votes
5 answers
32k views

OS X - How can a NSViewController find its window?

I have a Document based core data app. The main document window has a number of views, each controlled by its own custom NSViewController which are switched in as necessary. I want each of these view ...
AJ.'s user avatar
  • 1,256
52 votes
3 answers
14k views

Why are umbrella frameworks discouraged? [closed]

I want to distribute Framework A. Framework A depends on Framework B. I want a user of my framework to only need to include Framework A, but still have programmatic access to Framework B. Apple does ...
Ben Dolman's user avatar
  • 3,175
51 votes
7 answers
27k views

Get my Mac's computer name

How can I get the computer's name on a Mac? I'm talking about the same name as the one you can find in System Profiler under "Software".
Jonathan.'s user avatar
  • 55.2k
50 votes
5 answers
22k views

How do I quit a mac application programmatically?

I need to add a quit-button to my application that runs from the menubar in mac. How do I programmatically quit an application in mac?
Man of One Way's user avatar
50 votes
8 answers
30k views

How to Write OS X Finder plugin

I'm looking for a guide or sample code for writing Mac OS X Finder plugins? It would like to know how to do some simple actions: adding image overlayers to icons adding context menu items listen to ...
notnoop's user avatar
  • 59.1k
49 votes
6 answers
18k views

Fast enumeration on an NSIndexSet

Can you fast enumerate a NSIndexSet? if not, what's the best way to enumerate the items in the set?
cfischer's user avatar
  • 24.7k
49 votes
8 answers
16k views

NSTextField transparent background

I create transparent NSTextField self.myTextField = [[NSTextField alloc] initWithFrame:CGRectMake(backgroundView.frame.origin.x + backgroundView.frame.size.width + 20, self.projectTitle.frame.origin....
pawelropa's user avatar
  • 1,429
48 votes
6 answers
16k views

Callbacks When an NSScrollView is Scrolled?

I'm making a Mac app which needs to know when the user is scrolling the NSScrollView, however, I can't find any methods like UIScrollView, which has the following delegate methods: – ...
nonamelive's user avatar
  • 6,510
48 votes
4 answers
27k views

What is the File's Owner (in Interface builder)?

I am new to Cocoa and I don't understand the concept of File's Owner of a .nib file. Here is the way I would see things : Consider a file myNibFile.nib file that describes how a window looks. Now, I ...
Colas's user avatar
  • 3,553

1
2 3 4 5
271