objective-c

Extern C functions in Objective-c

Hi, i develop iPhone apps, and after updating to sdk 3.0, I get an error on CFWriteStreamCreateWithFTPURL while linking. This is the code I call to get the error. streamInfo.writeStream = CFWriteStreamCreateWithFTPURL(NULL, urlRefWrite); I have an idea that it can be solved using extern "C", but after having googled it, I have not fou...

Differences between Java interfaces and Objective-C protocols?

I know Java, and now I'm learning Objective-C. What exactly are the differences between Java interfaces and Objective-C protocols? ...

Objective-C : Object declaration question

Hello there is something I try to understand. I have this object declaration in my AppsController-Class for a Cocoa Application NSMutableArray *personArray; In can put this declaration inside the Header file or inside the implementation of the class in the code file. It makes no difference. I can even put it outside the @implementati...

Read regex value from array to set PopUpButton accordingly

I've got an XML file which I read in as a mutable array (NSMutableArray). It stores information like ( as given out by *NSLog(@"%@:%s GUI data: %@", [self class], cmd, guiData); ) { Name = "PopUp1"; RegEx = "^(Person|Group|Other)\Z"; Description = "Please select from list..."; Title = "Type"; } So now, how do I acces...

How would you give an Outline View alternating row colors?

I know there is a check box for it in IB but that only gives you the colors White and Blue. How would I make it so that it used different colors? ...

(Objective-)C ints always initialized to 0?

Is it safe to count on ints always being initialized to 0 in C? More specifically, when an object with int ivars has been newly instantiated in Objective-C, is it safe to assume that those ivars have value 0? ...

How can I keep an NSPopUpButton open after the user selects a menu item?

I have an NSPopUpButton providing the NSMenu for a status item with a custom view. The popup button displays a list of links. When the user selects a link from the list, the link is displayed in the user's browser (in the background). Naturally, the menu closes every time the user selects a link. I would like to change this: I want t...

iphone error: expected '=', ',', ';', 'asm' or '__attribute__' before ' 'foo'

I'm trying to port the speakhere example into another app and I'm having issues. I copied all the files, and all the frameworks, but for some reason I get a bunch of compile errors that I've never seen before and thus don't know what to do. The only difference is that i'm not suing IB and so i had to change it slightly. What does er...

Cocoa Touch Question. Should [NSMutableArray array] be retained?

Here is the gist of some code I'm writing. I'm concerned that I am not properly addressing the retain/release issues with the array class method on NSMutableArray. Is the following actually leaking memory? for(a while) { // do stuff NSMutableArray *a = nil; // do stuff if (!a) { a = [NSMutableArray array]; }...

Load NSPopUpButton dynamically content from XML file

How do I populate the content values of a NSPopUpButton dynamically using a XML file? I need to use arrays, right? Please, please provide example code. ...

Obj - C: Having trouble creating a UITableView that updates cells from an HTTP API in real-time (one at a time)

I am polling an HTTP API - it returns one item at a time, in real-time (about every 4 seconds). As each item is received, I would like a new UITableView cell to be populated. The full list of received items must remain in a class property, I'm guessing an NSMutableArray. What is the best way to initialize an NSMutableArray as a class pro...

Setting value of instance variable dynamically

Hi all, I'm trying to set the value of an instance variable dynamically at runtime in Objective-C. Assume I have a class called stock which has an instance variable float price. I have the following code: stock* s; ...//initialisation etc float newPrice = 12.56; Ivar variable = class_getInstanceVariable(NSClassFromString(@"stock"), "pri...

Static constructor equivalent in Objective-C?

I'm new to Objective C and I haven't been able to find out if there is the equivalent of a static constructor in the language, that is a static method in a class that will automatically be called before the first instance of such class is instantiated. Or do I need to call the Initialization code myself? Thanks ...

NSDate Problem

I have the following code below that is meant to change a class var called "today" forward or backward by one day. It will work one time but then after that it crashes. It will do the same no matter if I press the left button or right button. What am I doing wrong? the var today is a class var initiated as .. today = [NSDate date] Here...

Is there a difference between delegate/selector and target/action?

When writing Cocoa and implementing a class method that accepts a delegate and one or more selectors to use for its callbacks, does the terminology change from "delegate" and "selectors" to "target" and "action"? More to the point, is "delegate" limited only to when my class is the one getting called, but not when my class is doing the ...

Subclassing NSOutlineView

How would you Subclass an NSOutlineView? ...

Nested UIScrollViews in [REDACTED] - Controlling Which View Gets the Touch

I have a paged horizontal scroll view which houses uiwebviews. Scrolling side to side triggers the container uiscrollview scroll. Scrolling perfectly up and down triggers the uiwebviews scroll. Anything less than a perfect up-down swipe cause the horizontal scroll to trigger. This is all out-of-the-box [REDACTED] code. What I desire...

how to retrieve values from nsdictionary in iphone?

i am using a function to fill dictionary in a array here is the code -(void)getAllFlashCardsNames { if ([listofitems count]==0) listofitems = [[NSMutableArray alloc] init]; else [listofitems removeAllObjects]; for(int i=0;i<listOfCategoryId.count;i++) { int j=[[listOfCategoryId objectAtIndex:i]intValue]; [self getFlashCard:j]...

What's the easiest frame by frame animation technique in the iPhone sdk?

Hi, i've been developing for the iphone platform for about 3 weeks now, and I'm trying to set up a frame by frame animation with 16 1000x1000 png images (with transparency) and plan on animating with around 100 later, so first I tried using imageNamed to animate all the images like this -(IBAction)startClick1:(id)sender { clou...

How do I iterate over an NSArray?

I'm looking for the standard idiom to iterate over an NSArray. My code needs to be suitable for OS X 10.4+. ...