objective-c

Setting an object nil versus release+realloc

This is not a garbage collected environment I have a class instance variable which at some point in my runtime, I need to re-initialize with a different data set than it was originally constructed with. Hypothetically speaking, what if I have an NSMutableArray or an NSMutableDictionary, would it be more efficient to do something such a...

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? ...

Read network traffic bytes received and sent in objective c

What is the easiest way to get the network traffic sent and received bytes in objective c? ...

Objective C Boolean Array

I need to utilize an array of booleans in objective-c. I've got it mostly set up, but the compiler throws a warning at the following statement: [updated_users replaceObjectAtIndex:index withObject:YES]; This is, I'm sure, because YES is simply not an object; it's a primitive. Regardless, I need to do this, and would greatly appreciate...

QTKit, opening input devices???

I'm trying to add two inputs to a QTCaptureSession in the following: mainSession = [[QTCaptureSession alloc] init]; BOOL success; NSError* error; QTCaptureDevice *videoDevice = [QTCaptureDevice defaultInputDeviceWithMediaType:@"QTMediaTypeVideo"]; success = [videoDevice open:&error]; QTCaptureDevice *audioDevice = [QTCaptureDevice de...

iPhone SDK: POSTing NSData with NSMutableURLRequest results in mysterious crash

I'm seeing a crash that happens 10 or 20 seconds after a POST request I make has finished (didReceiveResponse, didReceiveData and connectionDidFinishLoading all fire well before the crash happens). This is the code I'm using to make the request: NSURL* url = [[NSURL alloc] initWithString:urlString]; [urlString release]; NSData* reques...

objective-c setter 2d-array

Hi, i want to initialize a 2d array.. but my code doesn`t work, can somebody tell me what is wrong? Thanks Chris @interface Map : NSObject { int mapData[8][8]; } @property(readwrite) int** mapData; @end @implementation Map @synthesize **mapData; (Error: Syntax before *) - (id)initWithMap:(int[8][8])map { for (int i=0; i...

How to set up HTTP connection in a special class?

I want to create a class to handle all the HTTP connection work for other classes(in order to avoid writing codes repeatedly). I call it ConnectionCenter(subclass of NSObject) and add the following codes to it: -(void)connect:(NSString *)strURL obj:(ConnectCenter *)objConnect { NSURLRequest *theRequest=[NSURLRequest requestWithURL:...

A static SegmentedControl in a NavigationController, loading appropriate ViewControllers

I have 2 separate TableViewControllers. At one particular instance I would like to be able to load a ViewController which will place a SegmentedControl in the NavigationController...which in turn will load the appropriate TableViewController. Currently I have the SegmentedControl just pushishing the correct TableViewController and it...

UITableViewCell weird behavior when table is scrolling out of view..

I have a class which extends UITableViewCell. For the purpose of this exercise, let's call it "CustomCell". In CustomCell, I have a UIImageView IBOutlet setup. The image instance name in this case is myImage. I wish to display this image based on certain criteria that's coming back from a server. That data is a dictionary which in this e...

iPhone SDK: UIWebView

I'm working on an app that uses a UIWebView to display its help files. The webView lives in it's own view, DocViewController...when its called the - (void)viewDidLoad { method uses [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource:docPage ofType:@"html"]is...

NSMutableArray add new methods

Hello, After some research i found a piece of code which shows how to expand NSMutableArray functionality to use 2d arrays easily. http://www.seattlexcoders.org/shared/Mutable%202D%20Array/ How would my declaration statement of this special NSMutableArray look like? With the following #import "ZNMutable2DArray.h" @interface MainView...

Creating mask with CGImageMaskCreate is all black (iphone)

I'm trying to create an image mask that from a composite of two existing images. First I start with creating the composite which consists of a small image that is the masking image, and a larger image which is the same size as the background: UIImage * BaseTextureImage = [UIImage imageNamed:@"background.png"]; UIImage * MaskImage = [UI...

detecting fullscreen on mac

I am writing an IM client for Mac (in python, but an Objective C / Cocoa solution here is fine). I want to detect whether or not the user is currently watching a movie or playing a game in the foreground, or doing anything else that takes up the entire screen. If so, I won't play a sound when a new IM comes in, but if not, I will play th...

How to design a static class?

I want to create a special class for holding a lot of values like strName, strNo, intPassword...So that several other classes can modify the same value in this class. I want to use the dot syntax to call its properties like Values.strName = ...; I don't want to initialize the class everytime before I read/write its values because some o...

What is a referencing outlet?

I just recently upgraded my copy of Xcode 3 to Xcode 3.1, and I noticed something new in interface builder - the referencing outlet. Can anyone explain what referencing outlets are, and how they relate to mac development? ...

Watch functions value

Hello all, I'm trying to make a simple iphone app that has two buttons: Start and Stop. When you hit start it starts listening to the phone's microphone volume and makes label show how loud you're talking into the mic. When you hit stop, it stops listening. I found a great class called SCListener, but I'm not sure how to get it impleme...

NSMutableArray count always returns zero

I'm sure I'm doing something silly, but this is driving me crazy. I'm trying to loop through database results, create objects from those results, and add the objects to an NSMutableArray. I've verified via NSLog calls that the data is being correctly read from the database and copied to the object, but the count for the NSMutableArray a...

UISegmentedControl Behaviour

Hey guys, A quick question about the UISegmentedControl class on the iPhone. Hopefully, some may have noticed how in its default state with 2 segments, the segmented control still will toggle even if the user taps on a segment that is currently selected. I've seen UISegmentedControls in apps that negate that behaviour and don't toggle...

UIActionSheet - Unknown Number Of Buttons, How to know what to call?

Hey guys, I have a UIActionSheet with an undetermined number of buttons. I'll need to use the delegate method buttonClickedAtIndex: (or something similar) to decide what method to call when the user clicks a button. The problem is: how do I decide which button is clicked when different buttons will appear at different indexes in differ...