cocoa-touch

Change identifier for UIBarButtonItem programatically

Through Interface Builder I have the ability to change the Identifier of a UIBarButtonItem to something like "Add" (or "Undo", "Redo" etc...). This gives my button a nice "+" image. How can I set this programatically? The UIBarButtonItem does not accept a "setIdentifier" message. ...

How to know whether a UITextField contains a specific character

How would I say that if a UITextField has @"-" in it, do something. Right now my code is like this. It doesn't seem to work: if (MyUITextField.text == @"-") { NSRange range = {0,1}; [a deleteCharactersInRange:range]; MyUITextField.text = MyUILabel.text; } I know that I am doing something very wrong with the code. Please he...

What is NSConcreteData, and where is it defined?

The following code: [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:mapURL]] returns an instance of NSConcreteData as opposed to NSData (which I expected!). What does NSConcreteData represent, exactly, and why is it being returned instead of an instance of NSData? Further, where is this class defined? XCode is complaining th...

Placing elements into the UITableView footer, when to release them?

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { AViewController * aView = [[AViewController alloc] initWithNibName:@"myNib" bundle:[NSBundle mainBundle]]; return vintagePriceRowView.view; } I know this code needs a release... somewhere. But where? If I set the allocated AviewContro...

Why aren't the values being stored to the NSDictionary?

See the log statement comments at the end of the code snippet... acceleration.x is a decimal, but when I store it to the dict, it seems to be 0. NSDictionary *entry = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithDouble:acceleration.x], @"x", [NSNumber numberWithDouble:acceleration.y], @"y", [NSNumber numberWithD...

GMail won't open .txt attachment created by iPhone App, Depending on Size - I think There's a Bug in my MIME

I have created aand sent a short email with a .txt attachment in an iPhone app. If the attachment is about 10 lines long, GMail opens it just fine. If it's more than 20 or so lines, GMail chokes - it won't open the attachment, download the attachment, or even forward the email. Also, if I send the same email to my colleague and he ope...

Trouble firing a [tableView reloadData]

I have a controller that contains a tableView that spawns another controller modally to enter a name in. Once the name is entered the modalview is released. But... how do I tell the first controller to [tableView reloadData]. I have tried in the ViewWillAppear, ViewDidAppear, etc... none of them will fire off the command because the firs...

iPhone: I'm trying to use an if statement but it's not working for me.

(Nearly solved, but not quite) (My temporary solution is to use a void method and call it in every button, and in that way I can edit the code used by multiple buttons rather then when making improvements having to edit each individual buttons if statement) I bet it's a really simple error i've made, but I can't find it. I'm trying to ...

Question about extensiblity of Cocoa Touch Controls

I'm new to programming for the iPhone and i'm wondering: how extensible are the various controls? Let's take the button as an example: can i change the background graphic? can i make it grow larger when i press on it? can i change the font? can i use a custom font? can i use a button graphic in place of text? ...

Maintaince of CoreData Application

If you change an anything (entity, relationship, type of attribute etc) in a CoreData model after it has shipped, what is the general process that you have to go through to get the user's store updated for your new model. ...

getting number of bytes from an instance of NSMutableData

I want to be able to determine if the number of bytes in an instance of NSMutableData is equal to zero. How would I do this? ...

UIButton title and image alignment query

I have a UIButton and I am trying to set a title and an image on it. I would like to align the title for a UIButton to the left side and place an image aligned to the right. I am trying to get the look and feel of the button in Timer in Clocks app (the one which says "When Timer Ends"). I fiddled with contentHorizontalAlignment, conten...

Detecting when modal view has been displayed

This is a fun one... I have an application that has a help screen and is displayed as a modal view. The main view has an action that occurs when the device is shaken. I do not want the action to occur (sounds are played) when the help screen has been displayed. I have tried a few things... here is my code: To display the help screen...

Copy from a UITextView without having the keyboard showing

I display a UITextView that I want the user to be able to copy from but not edit. There must be no keyboard present on the screen during the copy. If I prevent first responder then the keyboard stays hidden. However this also prevents processing of events from touches that would allow a copy interaction. It also has to be editable to pr...

Determining the number of decimal numbers for a currency

On the iPhone: Using the US locale, a currency looks like this: $1,234.56 Using the UK locale, a currency looks like this: £1,234.56 Using the German (Germany) locale, a currency looks like this: 1.234,56 € and finally, a Japanese currency: ¥1,234 The Japanese currency has no decimals and this impacts my custom keyboard significantl...

Should I use the Data Persistence API or flat files to record GPS data on the iPhone?

I'm building a GPS recorder app for the iPhone, and I was wondering if anyone could say why I might use the data persistence API, instead of writing data to flat files? ...

commitEditingStyle method not firing?

I have a tableView that I want to allow editing and delete rows. I make it go into editing mode fine. But when I press the delete button it's not firing off the event to make it delete the row!?? Here is my code: - (IBAction)editTable:(id)sender{ ; if(self.editing){ [super setEditing:NO animated:NO]; [self.tableView setEditing:NO an...

Trying to create and write to file using NSFileHandle... and it doesn't seem to be working

What am I doing wrong here: NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; self.gpsFilePath = [documentsDirectory stringByAppendingString: @"/gpsReadings.txt"]; self.gpsFile = [NSFileHandle fileHandleForWritingAtPath:self.gpsFile...

How would I tint an image programatically on the iPhone?

I would like to tint an image with a color reference. The results should look like the Multiply blending mode in Photoshop, where whites would be replaced with tint: I will be changing the color value continuously. Follow up: I would put the code to do this in my ImageView's drawRect: method, right? As always, a code snippet would g...

Scrolling background image for UITableView?

There are currently a lot of answers on how to set a custom fixed background for a UITableView. But is there any trick to make the background image scroll together with the table cells? Thanks! ...