objective-c

How do you remove one-time-use class variables from Objective-C code?

I'm writing some Objective-C code and I've frequently hit the situation where I have to use a class variable to store a value for one time use. After consuming it I no longer need it. To me, storing this value in a class variable seems like code smell. Really the value should be passed in as a parameter to the methods I'm using. I ru...

Adding NSMutableString to NSArray

I'm having some trouble adding a mutable string (that has been changed with replaceOccurrencesOfString) to an array. This is related to another question I asked: http://stackoverflow.com/questions/2124860/remove-double-quotes-from-nsstring Here is the code //original String NSString *aString = @"\"Hello World\""; NSLog(@"Original Stri...

iphone uitableview - action on accessory click

hi all. I am trying to link the click of an accessory button in a UItableview to a method in a particular class. The accessory is on multiple cells, created in code, and thus I can't just do a simple link in interface builder like I am used to. How do I link an accessory arrow (from the end of a cell in a uitableview) to a method? Re...

iPhone alloc or string literals for NSString?

I have a quick question about the two examples below. Currently I am using the top example on the understanding that because of the iPhones limited resources I am better off allocating and releasing manually as apposed to using the bottom string literal example. Does anyone have a preference as to which one to go with? if(activeSegment ...

How to format float number (Objective-C)

Hi, i would like to know how to format float number. Float Want to display 1.0 1 1.52 1.5 1.58 1.6 ...

Getting a pointer or reference to a member of another object

Hi have an newbie issue with objective-c, cocoa & iPhone. I've declared mapView in my application delegates applicationDidFinishLaunching:application: which is instance/pointer of MKMapView class. mapView is a member of my application delegate. In my view controller in viewDidLoad: I get instance of my application delegate with the foll...

how to retrieve particular datas from html page in objective c

I am new to iPhone development. I want to display data taken from inside a html table from a web page. Is there any way to retrieve the data from the table in the html page? Html page is the source code of a page in a website. I have only the url of the webpage. From its source code(html file), I have to retrieve only a part of data from...

Problem naming NSTableColumn

Hi, I'm trying to create a column with an empty string as the identifier but Cocoa seems to replace the empty string with the word "Field" every time I try to create the column. How do you go around this? - (void)addColumnWithCheckboxToTable:(NSTableView *)table { // Add column with checkbox before all other columns // This col...

Using a UISegmentedControl to switch between multiple arrays using a uipickerview

I am working on a core data using app and one of the views is EditingViewController, which acts as the controller for a number of ui elements which describe the attributes of objects. Inside the EditingViewController, all of my ui elements are being called and hidden with the .hidden = YES/NO; operation. One of my ui elements is a uipick...

Cocoa global shortcuts?

Hi, I want to create a global shortcut for my app. I've used the 'cool new way' of doing this with the addGlobalMonitorForEventsMatchingMask method. The problem is, my events don't get "consumed": my shortcut includes the spacebar, so whenever I use the shortcut, Quicklook pops up when I'm in the Finder. How can I prevent this from hap...

NSDateFormatter with 24 hour times

Hi, I have a countdown timer which countsdown from the current date/time to a specific future date/time. It is working great except for one problem. I input the future date using NSDateFormatter and dateFromString. It doesn't seem to be able to accept any time (hour) over 12 though indicating it is not support 24 hour clock. Is there a w...

Is it possible to download images, videos onto the iphone?

I am building an application where we do updates for images and videos and was wondering if it was possible to download videos/images from a web-service that will host these assets somewhere on the iphone programatically? Maybe through a curl service or ftp? ...

__deprecated__ not triggering compiler warning with subclass

I have a few subclasses of UITableViewCell from the 2.0 days that override the deprecated designated initializer: - (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier This code does some additional setup for the cell and I'm converting the classes to use the new designated intializer: - (id)initWithStyle:(UIT...

int / float to NSString without using alloc?

Is there anyway to get int (or float) numbers into a NSString object without using alloc and a subsequent release? int myInt = 25; NSString *myString = [[NSString alloc] initWithFormat:@"%d",myInt]; ... [myString release]; EDIT: Thanks for the answers, I should have been a little more clear in the question, I am particularly interes...

Override decidePolicyForNavigationAction what next?

In my first view I've overridden decidePolicyForNavigationAction, now I want to pass 'request' to another view that will be pushed onto the navigationController stack, which will display the content from the url in a uiwebview My problem, I think, is pushing the next view onto the stack, I keep getting 'request for member 'navigationCon...

reading/writing files to Windows Azure storage using Objective C

Does anyone know of any good resources or tutorials on how to write files to Windows Azure and read the files using Objective C? (for an iPhone app) Thanks! ...

Setter Getter oddness @property

I am having a really odd problem trying to set a simple float value to 1. My property: { float direction; } @property(nonatomic)float direction; Which is synthesized: @synthesize direction; I then used the following code: - (void)setDirection:(float)_direction { NSLog(@"Setter called with value of %f",_direction); self->d...

Objective C: Return an array of objects from a class method

Hi Everyone I've done a fair bit of searching and not really found an answer to my question so was hoping someone might be able to point me in the right direction I'm new to Objective C and am having a slight issue carrying out something that I would imagine is quite simple; returning an NSArray of objects from a class method I have t...

memory leaks appearing after multiple loading

Hi everyone I have an, at least to me, strange case here: I have a relatively simple program which loads an XML file from the web, parses it and write the data into an array of dictionaries. Each dictionary represents a row in the table. The program works fine and if I attach my simulator to instruments and load the list, there is no me...

What's the best way to store and retrieve multi-dimensional NSMutableArrays?

I'm storing a bunch of data in a .plist file (in the application documents folder), and it's structured like this: Dictionary { "description" = "String Value", "sections" = Array ( Array ( Number, ... Number ), Array ( Number, ... Num...