Skip to main content
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', ...
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 ...
Brock Woolf's user avatar
  • 47.3k
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?
Andy Jacobs's user avatar
  • 15.2k
205 votes
11 answers
152k views

How to get pixel data from a UIImage (Cocoa Touch) or CGImage (Core Graphics)?

I have a UIImage (Cocoa Touch). From that, I'm happy to get a CGImage or anything else you'd like that's available. I'd like to write this function: - (int)getRGBAFromImage:(UIImage *)image atX:(int)...
Olie's user avatar
  • 24.7k
19 votes
3 answers
3k views

Getting date from [NSDate date] off by a few hours

I am using NSDate *date = [NSDate date]; for getting the date, but the date I get is off by 2 hours.
YosiFZ's user avatar
  • 7,880
193 votes
12 answers
79k views

What's the Best Way to Shuffle an NSMutableArray?

If you have an NSMutableArray, how do you shuffle the elements randomly? (I have my own answer for this, which is posted below, but I'm new to Cocoa and I'm interested to know if there is a better ...
Kristopher Johnson's user avatar
158 votes
9 answers
53k views

How does an underscore in front of a variable in a cocoa objective-c class work?

I've seen in a few iPhone examples that attributes have used an underscore _ in front of the variable. Does anyone know what this means? Or how it works? An interface file I'm using looks like: @...
Atma's user avatar
  • 29.7k
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 ...
Allyn's user avatar
  • 20.4k
341 votes
6 answers
538k views

How do I use NSTimer?

How do I use an NSTimer? Can anyone give me step by step instructions?
lab12's user avatar
  • 6,450
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 ...
Coocoo4Cocoa's user avatar
  • 50.6k
336 votes
10 answers
139k views

NSString property: copy or retain?

Let's say I have a class called SomeClass with a string property name: @interface SomeClass : NSObject { NSString* name; } @property (nonatomic, retain) NSString* name; @end I understand that ...
Debajit's user avatar
  • 47.1k
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?
mk12's user avatar
  • 26.3k
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
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 ...
Dev's user avatar
  • 7,046
103 votes
13 answers
95k views

HTML character decoding in Objective-C / Cocoa Touch

First of all, I found this: Objective C HTML escape/unescape, but it doesn't work for me. My encoded characters (come from a RSS feed, btw) look like this: & I searched all over the net and ...
treznik's user avatar
  • 8,104

15 30 50 per page
1
2 3 4 5
410