39,634 questions
1412
votes
39
answers
517k
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 ...
1331
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', ...
1048
votes
14
answers
449k
views
Constants in Objective-C
I'm developing a Cocoa application, and I'm using constant NSStrings as ways to store key names for my preferences.
I understand this is a good idea because it allows easy changing of keys if ...
776
votes
20
answers
387k
views
How do I create delegates in Objective-C?
I know how delegates work, and I know how I can use them.
But how do I create them?
729
votes
10
answers
270k
views
Cocoa Autolayout: content hugging vs content compression resistance priority
I can't find a clear answer on Apple documentation regarding Cocoa Autolayout about the difference between content hugging and compression resistance.
Can somebody explain their usages and ...
718
votes
16
answers
172k
views
@class vs. #import
It is to my understanding that one should use a forward-class declaration in the event ClassA needs to include a ClassB header, and ClassB needs to include a ClassA header to avoid any circular ...
660
votes
9
answers
181k
views
What does the NS prefix mean?
Many classes in Cocoa/Cocoa Touch have the NS prefix. What does it mean?
634
votes
14
answers
231k
views
Cocoa: What's the difference between the frame and the bounds?
UIView and its subclasses all have the properties frame and bounds. What's the difference?
572
votes
8
answers
166k
views
@synthesize vs @dynamic, what are the differences?
What are the differences between implementing a @property with @dynamic or @synthesize?
452
votes
13
answers
147k
views
How to print out the method name and line number and conditionally disable NSLog?
I'm doing a presentation on debugging in Xcode and would like to get more information on using NSLog efficiently.
In particular, I have two questions:
is there a way to easily NSLog the current ...
427
votes
13
answers
147k
views
throwing an exception in objective-c/cocoa
What's the best way to throw an exception in objective-c/cocoa?
418
votes
9
answers
109k
views
Is It Possible to NSLog C Structs (Like CGRect or CGPoint)?
I want to be able to debug C structures without having to explicitly type every property that they consist of.
i.e. I want to be able to do something like this:
CGPoint cgPoint = CGPointMake(0,0);
...
394
votes
9
answers
209k
views
How do I convert NSMutableArray to NSArray?
How do I convert NSMutableArray to NSArray in objective-c?
363
votes
25
answers
51k
views
Exception thrown in NSOrderedSet generated accessors
On my Lion app, I have this data model:
The relationship subitems inside Item is ordered.
Xcode 4.1 (build 4B110) has created for me the file Item.h, Item.m, SubItem.h and SubItem.h.
Here is the ...
363
votes
12
answers
190k
views
Best way to define private methods for a class in Objective-C
I just started programming Objective-C and, having a background in Java, wonder how people writing Objective-C programs deal with private methods.
I understand there may be several conventions and ...