objective-c

How to declare an array of floats as a class variable in Objective-C when the dimension is undefined at the class instantiation time?

In Java, it would look like this: class Foo { float[] array; } Foo instance = new Foo(); instance.array = new float[10]; ...

Objective-C Clarification; -/+ and *var

I'm teaching myself Objective-C from a book (Cocoa programming for mac OS X) and am about halfway through however I have two questions that aren't answered or defined in the book. When defining class methods what is the difference between (assuming there in a .h file): - (int) population; + (int) population; The way I see it at the...

How can I get a value from UITextField in UIAlertView ?

I have Used in cocos2d game engine. this is my code: -(void)timed1: (id)sender { UIAlertView *dialog = [[[UIAlertView alloc] init] retain]; [dialog setDelegate:self]; [dialog setTitle:@"Enter Time:"]; [dialog setMessage:@" "]; UITextField *nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 2...

Having a UITextField in a UITableViewCell

Hi! I'm trying to do that for a couple of days now, and after reading tons of messages of people trying to do that too, I'm still unable to have a fully working UITextField in some of my UITableViewCells, just like in this example: http://img231.imageshack.us/img231/4858/picture4za3.png Either I have the form working but the text is ...

Running a Socket Server in Cocoa

I'm trying to write a program that uses sockets to connect with other instances of itself over the network. Since eventually I'd like to write a Windows version as well, I'm currently using BSD sockets on the OS X side so that I can ensure that it will be compatible with the (eventual) Windows version. The only way that I've been able t...

Editable NSTableView with Bindings won't set values in model

Here is my setup. In my application delegate, I have a property called currentFoo. The currentFoo property is set to the currently selected Foo instance. The Foo instances each have a property which is a NSMutableArray called results. The objects in results can be of various types, NSNumber, NSString, etc... I have an NSTableView that...

C#/.Net equivalent of NSNotification

I'm an Objective-C developer porting an application to the .Net world. In my Obj-C application, I use NSNotification objects to communicate asynchronously between a handful of objects. Is there some way to do something similar in the .Net world (more specifically, using the C# language)? The fundamental approach is that one object posts ...

Creating a UITableView with Taller Cells on the iPhone

How can I go about creating a UITableView with taller cells? Basically, I want to create a full screen table with only four cells, but they should take up the entire screen (1/4 each). Assuming this is possible using a UITableView, can it be done both in code and in Interface Builder? And also, can each cell have its own height? --Tim ...

Is there a difference in term of performance between "unsigned int" and "int" on the IPhone?

Or to reformulate the question: is there a performance penalty in using unsigned values? And in general: what is the most performant type (16bit signed?, 32bit signed? etc.) on the IPhone ARM processor? ...

Convert between a C double and Cocoa's NSDecimalNumber?

I'm converting an algorithm I wrote in Java to Objective-C. In java the BigDecimal class handles base-10 numbers and can take the primitive double as a constructor arg. In Cocoa's NSDecimalNumber class, however, there is no direct way to construct an instance using a primitive double. Currently I'm using this (smelly) hack: [NSDe...

Which text field did the user click in?

My iphone app has several text fields. The "Did End on Exit" event on each text field calls a single action. How can I tell which text field called the action? Can I detect this from the sender object which is passed to the action? ...

Problem compiling gnustep-gui-0.16.0 undefined reference to png_sizeof

I'm trying to compile GNUstep on a linux box but gnustep-gui-0.16.0 package is failing. I downloaded GNUstep Startup stable 0.20.1 (http://wwwmain.gnustep.org/resources/downloads.php)and follow instructions about how to compile (./configure && make). I'm getting this error: libgnustep-gui.so: undefined reference to 'png_sizeof' I have ...

Execute a terminal command from a Cocoa app

Hi How can I execute a terminal command (like grep) from my Objective-C Cocoa application? Thanks. ...

Best way to work with an array of pointers in Objective-C?

I'm trying to mimic the following Java code: int[][] multi; // DIMENSIONS ARE UNKNOWN AT CREATION TIME // LATER ON... multi = new int[10][]; multi[5] = new int[20]; multi[5][11] = 66; // LATER ON... multi = null; // PROPER WAY OF FREEING EVERYTHING I've came out with the following Objective-C version: int* *multi; // multi = malloc(1...

NSNumber storing float. Please NO scientific notation!!

(iPhone question) My code looks like this NSNumber *inputToNumber = [NSNumber numberWithFloat:[textField.text floatValue]]; the value from the textfield is actually a telephone number. It's stored in NSNumber as an annoying (2.0)78966e+08 How can I just get NSNumber to store it as 0207896608? Thanks dan ...

Instance caching in Objective C

Hello! I want to cache the instances of a certain class. The class keeps a dictionary of all its instances and when somebody requests a new instance, the class tries to satisfy the request from the cache first. There is a small problem with memory management though: The dictionary cache retains the inserted objects, so that they never ge...

How can get the value of text field by a alart view using cocos2D ?

I am trying to develop a application by using cocos2d. I can't getting value from textfield . How can get the value of text firld (in a alart view) by using COCOS2D ? -(void)timed1: (id)sender { UIAlertView* dialog = [[[UIAlertView alloc] init] retain]; [dialog setDelegate:self]; [dialog setTitle:@"Enter Time:"...

Is garbage collection supported for iPhone applications?

Does the iPhone support garbage collection? If it does, then what are the alternate ways to perform the operations that are performaed using +alloc and -init combination: NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:xmlData]; UIImage *originalImage = [[UIImage alloc] initWithData:data]; detailViewController = [[[DetailView...

How to use "takeStringValueFrom" with Button onclick Event?

I have a button that correctly wired such that when it is clicked, the "login" IBAction is hit. - (IBAction) login: (id)sender { NSLog(@"OK"); } Now, I wired the button to the username/password text fields using "takeStringValueFrom" but I don't understand how to then get at those values? Hope that makes sense. EDIT: so basica...

Cocoa/Objective-C - Can i somehow see the implementation files?

I believe i can learn thing or two if i can see the implementation files (.m files). Is there any way the i can view NSString.m or NSNumber.m files? and others? If i try to find these files using spotlight, i get nothing. ...