objective-c

Does +(void)initialize do any thread locking?

Looking at the definition for "initialize": + (void)initialize Discussion The runtime sends initialize to each class in a program exactly one time just before the class, or any class that inherits from it, is sent its first message from within the program. (Thus the method may never be invoked if the class is not used.) The runtime s...

Can't find the leak in this Objective-C NSXMLParser code?

I am new to iPhone programming, and am running my app against the Leaks tool in Instruments. The tool is finding a few leaks, all of which seem to point to 1 line of code in a class which uses NSXMLParser: - (BOOL)parse{ NSURL *url = [[NSURL alloc] initWithString:@"[url here]"]; NSXMLParser *parser = [[NSXMLParser alloc] initW...

Forwarding method calls to a method with a different signature in Objective-C?

I am trying to implement a JSON-RPC solution, using a server connector object wich obtains a list of available functions from a server somehow like NSDictionary *functions = [server callJSONFunction: @"exposedFunctions" arguments: nil]; wich is a simplified description, since callJSONFunction actually triggers an asynchronous NS...

syntax highlight with objective-c

Hi Guys, i'm looking for a objective-c class that supports syntax hightlighting a string. is there something like that existing? this should work on iphone! ...

Moving Between Multiple XIB Files

Hi, It's my understanding that in order to move between xib files one usually uses either a Navigation Controller, Tab Controller, or Flipside Controller or combination of them. But my question is- can I write my own custom controller, and use Core Animation to move between Views or are these default controllers (navigation/tab/flipsid...

get value of selected row NSTableView

how can i get value of selected row in NSTableView? ...

removing bounce off colliding objects in box2d

Hi, I am trying to delete an object in box2d when 2 object collide. When my 2 objects do collide, one of the object bounces off the other. it does delete the other object, but i want it to make it look like it went through rather than a bounce. I have my body Def type set to b2_staticBody. Any help would be appreciated. ...

Wait until Preference Pane is completely visible to show sheet?

I'm writing a preference pane to control a script I created, and I want to show a sheet on first launch so the user can tell the pane where they installed the script. The sheet appears fine, the problem is that it appears right after you click the button for my pane. This causes System Preferences to Segmentation Fault immediately. I'm ...

How much memory can an iPhone app use?

Can anyone link me to a page that describes memory allocations for iPhone apps. I have heard that you are limited to a sandbox of ~20 megs, depending on the state of the phone, but I can't find the source for this. ...

Objective C Introspection/Reflection

Is there a built in method, function, API, commonly accepted way, etc. to dump the contents of an instantiated object in Objective C, specifically in Apple's Cocoa/Cocoa-Touch environment? I want to be able to do something like MyType *the_thing = [[MyType alloc] init]; NSString *the_dump = [the_thing dump]; //pseudo code NSLog("Dumped...

How can I determine the default gateway on iPhone?

I need to obtain the IP address of the default gateway in an iPhone application. I cannot find the proper API. Anyone know if iPhone exposes this information? ...

Fast Enumeration With an NSMutableArray that holds an NSDictionary

Is it possible to use fast enumeration with an NSArray that contains an NSDictionary? I'm running through some Objective C tutorials, and the following code kicks the console into GDB mode NSMutableArray *myObjects = [NSMutableArray array]; NSArray *theObjects = [NSArray arrayWithObjects:@"easy as 1",@"easy as two", @"Easy as Three"]; ...

No key/value pairs being saved in NSMutableDictionary

When my app starts, it loops through adding values of random numbers with keys of co-ordinates on a grid to a dictionary. Here is a bit of the code: [grid setObject:v forKey:k]; K is a string in form "xy" where x and y are single digit integers and V is an NSNumber. Both of these are logged to the console before adding so I know these...

Why is presentModalViewController hindering UITextField responses?

Any uitextfield I add to a view which is presented from another view controller with presentModalViewController:animated: does not respond to any touch events (like the keyboard doesnt display when the uitextfield is tapped) also if i use [textField becomeFirstResponder] to force the keyboard to display, the only time this works is in th...

How can I avoid "duplicate symbol" errors in xcode with shared static libraries?

I have static libraries A, B and C organized into Xcode projects. A and B depend on C. When I build an iPhone project that depends on A and B, I get a linker error that a duplicate symbol (from C) was detected in A and B. How can I organize these three static libraries so I can include them in other Xcode projects without experiencing...

How safe are Objective-C categories?

Objective-C categories are extremely useful, but there are some problems with this power. These come in basically two forms which I know of: Two categories attempting to add the same convenience method. In this case, it is undefined which one is used. If you are careful - not adding too many methods or using particularly common method ...

check if value is integer or double in objective c

Hi, I have a case where I should get the elements from an array and I do not know if the type is double or integer. [array objectAtIndex:2] and the problem is that I can not identify the type. If i knew the type I simply would perform: [[item objectAtIndex:2] intValue] or [[item objectAtIndex:2] doubleValue] Is there any way to detect...

How to customize iPhone UISlider control at runtime - where do I place the color update code?

I have added a UISlider control to an iPhone View-based application and have wired up a text field that gets the values from the slider. To fit with the user interface colors in the application I need to change the color of the slider. With a little googling I was able to find 2 samples which do this (http://blog.hill-it.be/post/2009/03...

sending messages across views

I need to tell a uitableview to reloadData when something happens on another view (or at least that is what I think I need to do) how do I do it?? the uitableview is just an IBOutlet of a uitableviewcontroller object. more details: So i have an array of data as kind of a database and a user creates objects to populate the database on v...

how can i retrieve the text data from sqlite datadase in objective-c ?

i am using this -(void) Data { databaseName = @"List.sqlite"; NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [documentPaths objectAtIndex:0]; databasePath =[documentsDir stringByAppendingPathComponent:databaseName]; [self ch...