objective-c

How can I access variables from another class?

There is probably a very simple solution for this but I can't get it working. I have got multiple classes in my Cocoa file. In one of the classes class1 I create a variable that I need to use in another class class2 as well. Is there a simple way to import this variable in class2? ...

Mac OSX/iPhone error handling in the App Delegate?

Hi all, I'm curious, how do most of you folks handle errors such as HTTP Forbidden or 5xx type requests from a server? Or say an exception is thrown in one of your UIViewControllers? Do you typically bubble up the error to the App Delegate and handle generic "window" level errors at that point? Do you couple errors directly into the UIV...

Objective C HTML escape/unescape

Wondering if there is an easy way to do a simple HTML escape/unescape in Objective C. What I want is something like this psuedo code: NSString *string = @"&lt;span&gt;Foo&lt;/span&gt;"; [string stringByUnescapingHTML]; Which returns <span>Foo</span> Hopefully unescaping all other HTML entities as well and even ASCII codes like Ӓ a...

How do I read in a php array, in Objective-C?

In php I have: $result = mysql_query($query); // if successful query, return the records if ($result) { // if not empty result, return array of records if (mysql_num_rows($result)) { $records = array(); while ($row = mysql_fetch_assoc($result)) { $records[] = $row; } return $records; } } In Objective-C - After th...

How can I create an interface similar to an Excel spreadsheet on the iPhone?

Hi, I want to develop an iphone interface, using objective-c, which behaves like an Excel sheet. It would display a grid which can be scrolled vertically as well as horizontally but during a vertical scroll, the first row will freeze, and during a horizontal scroll, the first column will freeze. How can this be done? I am new to iphone...

objective-c class variables: when is dealloc called?

If I declare class variables in Objective-C, when is the memory released? If my interface is: @interface TestClass : NSObject { } + (NSString)instanceCount; @end And in the implementation, I declare: static NSString instanceCount; How do I release this class level variable? i.e. when is the dealloc called for class variables in ...

How to implement a large grid of cells in an iPhone application?

In reference to my previous question, I would like to know how to implement a large grid of cells in an iPhone application. I'm working on an interface which would be similar to an Excel spreadsheet, with many rows and columns. Do I have to handle each cell separately? How can I handle user interaction in each cell? Is there a standard...

Am I using NSUserDefaults wrong?

I've created a "Settings" model for my iPhone app. It only contains two properties and a class method for loading and one instancemethod for saving. I load it as follows + (UserSettings *)getCurrent { NSUserDefaults *userPrefs = [NSUserDefaults standardUserDefaults]; UserSettings *settings = [UserSettings new]; settings.use...

Bug in AlertView on iPhone?

I write a piece of code to "do something->show alert1->do something->show alert2". //do something UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert 1" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert re...

Open link in a new UIWebView?

Hi all.. I have made an app with a Tabbar and an RSS reader in one window. I know how to open the RSS links in the build in safari browser, but how do I open the links in a UIWebView in the same tab instead? I don't want to quit my app to view the webpage, and how do I go back to the RSS view? Simply by hiding the webview? Hope you ca...

Using libtidy for iPhone app

I'm trying to use libtidy for an iPhone app (since the iPhone 2.2 SDK doesn't include NSXMLDocument which has tidy functionality) but I get a linker error saying "library not found for -ltidy" when I build the app. As for other framework/library references, I've added the libtidy.dylib to my list of referenced frameworks and I've added ...

UITableView - what row was selected?

Hi, I have a question - how can I get a number of row selected in a table? I am assigning it manually to a variable. The problem is that if a row was deselected, my variable still keeps the old value. What can I do about it? Is there a method in UITableView that returns a number of a currently selected row? Thank you in advance, Ilya....

How can I pass arguments with UIActionSheet?

I have an Action Sheet popping up and I want to pass a certain argument to a button processing method. For example: I have a table and I want to pass to a button processing method row number that was selected in a table. How can I achieve this? ...

How to turn off startup text of GNU gdb in XCode

I'm new to XCode 3.1.2 and Objective-C 2.0. I've just discovered using breakpoints for logging instead of littering the code with millions of NSLog() statements. The problem is, when the debugger starts up it spews half a screen full of status and credits info into the console. Is there any way to suppress this text? ...

How does a Protocol on an instance variable in Objective-C work?

I see a lot of code such as the following as of late: id<foo> aBar; Typically this is something I'd see in a class declaration, such as: @interface bar : UIViewController <UITableViewDelegate, UITableViewDataSource> Does the above mean that aBar might be an instance of class bar and promises to have all of the methods declared in t...

NSNumberFormatter to format US Telephone Numbers

I'm trying to convert a string of numbers, entered by the user, into a sexy string like Phone.app on the iPhone. Here is the code I'm using, which doesn't work (no special format comes out) and after a certain number of digits it just starts adding "0" to the end of the string. NSNumberFormatter *formatter = [[NSNumberFormatter alloc] i...

How to release memory associated by CGImageCreateWithImageInRect

I am using CGImageCreateWithImageInRect() for generating a small image from a background image runtime, which is going to displayed for every thread call (0.01 sec). Once I start showing part of image through CGImageCreateWithImageInRect application starts consuming memory in very high rate and crashes within seconds. Memory consumed goe...

How can Play Audio file in loop without any interruption ?

I am trying to develop a simple iPhone app. I need to play sound within a loop. How can Play Audio file in loop without any interruption ? ...

how to make phone call by using objective c ?

hi to all, can anyone help me to do making phone call by using objective c. thanks in advance... ...

How may a linked list be saved/loaded from a file efficiently using Objective-C?

After four weeks of learning Objective-C for the iPhone, my first useful application is almost finished. However, I still need to save several instance variables whenever the current view is changed and to reload them when the view is reopened. I have no trouble loading variables with basic C types like int and BOOL, but am having diffi...