objective-c

How create an Global Variable for all the project type NSArray

Hello, I would like to know how can I create a global variable type NSArray that i can use (write in/read data) from any class from y app. At the moment i'm using NSUserDefaults, but I don't think this is the best option, because i'm saving one NSArray quite big. Thanks. ...

How to Identify tab bar items?

Hello, I would like to know how can I identify the items in the tab bar? I have a tabBarController that contain NAvigationController like this: NSMutableArray *localViewControllersArray = [[NSMutableArray alloc] initWithCapacity:6]; Each navigationController is inside this array. I manage the actions in each tab bar item with the ...

iPhone Exception Handling

I have one crash in my iPhone application that does throw an NSException. The crash reports are completely ambiguous in where the error is and what exactly is causing it. Is there a smart way for me to set a top level exception handler somewhere to see what is causing it? I can't replicate the problem myself, but a few of my beta users c...

I get error 0x8badf00d in iPhone app, and is not the usual suspect

I have a random crash in my app in launching. I'm pretty sure is not the launching time (as explained in http://stackoverflow.com/questions/773442/what-does-8badf00d-mean/779387) because the app launch fast. The worst is that the crash log can't be simbolicate (I can't get the sourcecode line numbers). This is the error: Exception Typ...

Obtain list of class methods for an arbitrary class

How can I get the list of class methods for a particular Class? I've tried using the class_copyMethodList function declared in <objc/runtime.h>, but that's only giving me instance methods. I've also found a function that gives me a Method for a class method, but only if I have the selector to the method first (class_getClassMethod). A...

OO Objective-C design with XML parsing

Hi, I need to parse an XML record that represents a QuizQuestion. The "type" attribute tells the type of question. I then need to create an appropriate subclass of QuizQuestion based on the question type. The following code works ([auto]release statements omitted for clarity): QuizQuestion *question = [[QuizQuestion alloc] initWithXMLS...

Is it possible to stop touches from getting added to the queue?

Hi, I have disabled interactions in my primary view (which contains some subviews I use as buttons). I keep this disabled while I have a secondary view up indicating network activity (loading data). When it is finished, I re-enable interactions in the primary view. This is so the user isn't tapping those buttons while the network oper...

Valid use of accessors in init and dealloc methods?

I've heard now from several sources (stackoverflow.com, cocoa-dev, the documentation, blogs, etc) that it is "wrong" to use accessors and settings (foo, setFoo:) in your init and dealloc methods. I understand that there is there is a remote possibility of confusing other objects that are observing the property if you do so. (a simple e...

get rid of ObjectAtIndex may not respond warning

I have a NSMutableArray which i am initializing from a plist with strings. but when i try to do objectAtIndex or removeObjectAtIndex on that array, I'm getting the warning "NSMutableArray may not respond to...." and it also fails at execution. how do i sovle this? thx ...

Generating HTML programmatically

In C#, I use XML/XSLT transformation to isolate markup from data. What's the equivalent in Objective C? ...

Is there a cocoa library for advanced date + time handling?

I need to do some date + time stuff that is not covered well by NSDate on the iPhone. I wonder if there is a library that has more sophisticated functionality regarding dates and time on a international level. What I want to do is advanced date + time mathemathics. I need to: convert between different calendar types (Gregorian <> Jewi...

Saving a string into file in Objective-C (iPhone)

Hi there, I seem to have stumbled over a problem regarding saving an xml file from a string (this is done on the iPhone) The file itself exists and included in the project (hence within the workspace), and all indications I get from the code snippet which follows passes without any errors on the emulator and fail on the iPhone (error 51...

NSDictionary From NSMutableData

I was previously using initWithContentsOfURL to download a plist into an NSDictionary, but this hangs the UI when run on the same thread so now I have moved to NSURLConnection the issue is that I can no longer call a method to init the NSDictionary with NSMutableData. What is the best way to take NSMutableData and place it into an NSDict...

iPhone Music Game Problem With Double Tapping Home Button

When the home button gets double tapped in the middle of my music game for the iPhone, a pop-up appears showing the name and artist of the song being played...how do I disable this pop-up ? I'm using the iPodMusicPlayer in MPMusicPlayerController and I don't want to have to use applicationMusicPlayer. Thanks. ...

Is there a way to iterate over an dictionary?

I know dictionaries as something where you need a key in order to get a value. But what would I do, when I need to iterate over all keys and values in that dictionary so that I know what keys are there, and what values are there? Is that possible to do? I know in JavaScript there's something called for-in-loop. But in objective-c / cocoa...

Do I have to autorelease this object?

I am creating an NSDictionary with -initWithObjectsAndKeys:. For every object I provide to that dictionary I call a selfmade method -createFooBarObject, which will create and return the object. Now the problem: The create method by definition should not release the object because it must return it, and the caller is responsible for rel...

Objective-C on GNUstep AutoReleasePool undeclared problem

I'm new to Objective-C and working in GNUstep and MinGW environment. I am compiling this code but having an error: #import "Foundation/Foundation.h" @interface C : NSObject { float f; } - (void) gamerHell: (NSString *) name : (NSString *) lastName ; @end @implementation C - (void) gamerHell: (NSString *) firstName : (NSString *...

Directed Graph implementation in Objective-C

Before diving in and rolling my own implementation in Objective-C, I'm looking around to try and find an iPhone SDK-compatible directed graph ("digraph") implementation. For the sake of this question, I'll lean on Wikipedia to define the term: Because ensuring the graph is acyclic or otherwise preventing infinite recursion is non-trivi...

UITableViewCells to be in center of UITableView

Hi, I want that my 4 cells will be in the center of my UITableView. Can't scroll the UITableView. That there will be the same height above the first cell and below the last cell. thanks ...

What is the difference between these two init methods?

As far as I know, the first one you have to release when you are done, and the second one you don't. Why would you use the first initialization over the second? NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"title", @"text", nil]; And NSMutableDictionary *dictionary = [NSMutableDictionary dict...