All Questions

886
votes
63answers
658389 views

What does this mean? "'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X"

I'm trying to link a UILabel with an IBOutlet created in my class. My application is crashing with the following error. What does this mean? How can I fix it? *** Terminating app due to uncaught ...
1174
votes
36answers
388085 views

How to check for an active Internet connection on iOS or OSX?

I would like to check to see if I have an Internet connection on iOS using the Cocoa Touch libraries or on OSX using the Cocoa libraries. I came up with a way to do this using an NSURL. The way I did...
665
votes
18answers
303503 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?
181
votes
9answers
125579 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)...
11
votes
3answers
2242 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.
180
votes
12answers
72323 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 wa...
155
votes
9answers
48443 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: @int...
949
votes
13answers
386359 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 necess...
684
votes
16answers
162615 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 inclus...
345
votes
6answers
478908 views

How do I use NSTimer?

How do I use an NSTimer? Can anyone give me step by step instructions?

Previous Next